首页 > Windows开发 > 详细

C#文件流写入方法

时间:2016-06-28 18:27:42      阅读:262      评论:0      收藏:0      [点我收藏+]
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();

  

C#文件流写入方法

原文:http://www.cnblogs.com/afei9527/p/5624233.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!