C# write stream to local file

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

上一篇:Photoshop绘画酸酸的青苹果教程


下一篇:c# webapi swagger