
- /// <summary>
- /// 将 Stream 写入文件
- /// </summary>
- public static FileStream StreamToFile(Stream stream, string fileName)
- {
- // 把 Stream 转换成 byte[]
- byte[] bytes = new byte[stream.Length];
- stream.Read(bytes, 0, bytes.Length);
- // 设置当前流的位置为流的开始
- stream.Seek(0, SeekOrigin.Begin);
-
- // 把 byte[] 写入文件
- FileStream fs = new FileStream(fileName, FileMode.Create);
- BinaryWriter bw = new BinaryWriter(fs);
- bw.Write(bytes);
- bw.Close();
- fs.Close();
-
- return fs;
- }
评价
排名
78
文章
3
粉丝
0
评论
0
ICP备案 :渝ICP备18016597号-1
网站信息:2018-2025TNBLOG.NET
技术交流:群号656732739
联系我们:contact@tnblog.net
公网安备:
50010702506256


欢迎加群交流技术