var utf8WithBom = new UTF8Encoding(true); using (var ms = new MemoryStream()) { using (var swr = new StreamWriter(ms, utf8WithBom)) { swr.Write("abc"); } File.WriteAllBytes(@"X:abc.txt", ms.ToArray()); }
var utf8WithBom = new UTF8Encoding(true); using (var ms = new MemoryStream()) { using (var swr = new StreamWriter(ms, utf8WithBom)) { swr.Write("abc"); } File.WriteAllBytes(@"X:abc.txt", ms.ToArray()); }