C# UTF-8 with BOM 编码
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()); }