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

C# write stream to local file

时间:2020-06-26 20:24:45      阅读:69      评论:0      收藏:0      [点我收藏+]

标签:color   div   stream   ring   cte   ESS   filename   using   ext   

Write the current to the local file.

 static void CopyStream(Stream stream, string destPath)
        {
            using (var fileStream = new FileStream(destPath, FileMode.Create, FileAccess.Write))
            {
                stream.CopyTo(fileStream);
            }
        }

The encoding way of C# writing and reading Chinese characters  is System.Text.Encoding.GetEncoding(936)

static void BinaryWriteLocalFile(string fileName, string msg)
        {
            using(FileStream fs = new FileStream(fileName, FileMode.CreateNew))
            {
                using (BinaryWriter bw = new BinaryWriter(fs, System.Text.Encoding.GetEncoding(936)))
                {
                    bw.Write(msg);
                }
            }            
        }   

 

C# write stream to local file

标签:color   div   stream   ring   cte   ESS   filename   using   ext   

原文地址:https://www.cnblogs.com/Fred1987/p/13195871.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!