File.WriteAllText(fileName, sb.ToString(), System.Text.Encoding.UTF8);
//using (StreamWriter sw = File.CreateText(fileName))
//{
// sw.Write(sb.ToString());
// sw.Flush();
// sw.Close();
//}
sb中有中文,開始的時候使用的是注釋部分的代碼,發現文件中存在亂碼,后來修改為 上面的代碼,解決問題。
转载于:https://www.cnblogs.com/wonder223/archive/2012/11/20/2779242.html