WriteToFileUtf8

   public static void WriteToFileUtf8(this MemoryStream stream, String path)
        {
            using (var writer = new FileStream(path, FileMode.Create, FileAccess.ReadWrite))
            {
                Encoding enc = new UTF8Encoding(false, false);
                var chars = enc.GetString(stream.ToArray());

                var bytes = enc.GetBytes(chars.ToCharArray());
                writer.Write(bytes, 0, bytes.Length);
            }
        }
Example:
var path = "C:\\doc.txt";

using (MemoryStream ms = new MemoryStream())

   ms..WriteToFileUtf8(path);
}

Description

Write File in UTF8 from MemoryStream

Details

Double click on the code to select all.

 

;