码迷,mamicode.com
首页 > Windows程序 > 详细

C#文件流写入方法

时间:2016-06-28 18:28:42      阅读:161      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!