使用Encoding.Unicode字符就不会乱码了,如下:
#region 写入TXT文本
private int WriteTXT(string path, string str)
{
int nReturn = 1;
System.IO.StreamWriter SW = new System.IO.StreamWriter(path, true,Encoding.Unicode);
try
{
SW.AutoFlush = true;
SW.WriteLine(str);
SW.Flush();
}
catch (Exception e)
{
BaseClass.WriteFile.WriteErrLog("WriteTXT " + str + " into " + Path.GetFileName(path) + ": " + e.Message);
nReturn = 0;
}
finally
{
SW.Close();
}
return nReturn;
}
#endregion