文本编码格式
//c#之如何转换文本文件编码格式为utf-8
string content = File.ReadAllText(path, Encoding.Default); File.WriteAllText(path, content, Encoding.UTF8);
//下面是C#在写文件时指定BOM头的代码:var utf8WithBom =newSystem.Text.UTF8Encoding(true);// 用true来指定包含bom//下面的代码是不需要BOM:var utf8WithoutBom =newSystem.Text.UTF8Encoding(false);swr =newStreamWriter("okbase.txt",false, utf8WithBom);
swr.Write("hello okbase.net!");

浙公网安备 33010602011771号