关于Tab分割写入TXT改名为XLS后乱码的问题
2009-01-15 15:11
225 查看
使用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
#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
相关文章推荐
- 关于键盘过滤驱动中写入文件乱码的问题的解决!
- 关于javascript从txt文件中读取内容出现乱码的问题
- 黑马程序员---关于使用dom4j写入数据时的乱码问题分析
- 关于使用IDEA读取txt文件出现中文乱码的问题
- 关于写入MySQL数据库乱码问题
- 关于写入txt文件的问题
- 使用Unicode字符集时用CFile把中文写入txt文件再用记事本打开出现乱码的问题
- 关于生成TXT文件的乱码问题
- 关于Manifest.txt 写入jar包的格式问题
- 使用Unicode字符集时用CFile把中文写入txt文件再用记事本打开出现乱码的问题
- 关于C++ Builder 和 Dephi读取文本文件TXT出现中文乱码的问题
- 关于hibernate中文写入mysql数据库乱码问题
- 关于web工程jsp@include 包含html和txt乱码问题的解决办法
- 关于jsp连接sql server2005 写入数据库中文乱码的问题
- 关于在TextBox中写入换行“\r”有用,但是在txt文件中使用“\r”无效的问题
- 更正ftp上传采用utf-8编码方式写入txt文件用IE打开出现乱码的问题
- 关于hibernate写入mysql数据库乱码的问题
- 解决关于打开plist文件乱码问题,plist转换为xml文件的txt文件!
- 关于java处理txt中文乱码的心得
- VC++6.0关于分割窗口的CSize初始大小不起作用问题的解释