stream为服务端接收的文件流
var bytes = new byte[stream.Length]; stream.Read(bytes, 0, bytes.Length); // 设置当前流的位置为流的开始 stream.Seek(0, SeekOrigin.Begin); var pathHead = HttpContext.Current.Request.PhysicalApplicationPath; if (!Directory.Exists(path)) Directory.CreateDirectory(path); var resultPath = path + "文件.后缀"; var fileStream = new FileStream(resultPath, FileMode.Create, FileAccess.ReadWrite); //文件写入 fileStream.Write(bytes, 0, bytes.Length); fileStream.Flush(); fileStream.Close();
时间: 2024-12-06 04:07:01