注册 登录
编程论坛 VB.NET论坛

[求助]在VS中,用VB编写一段写入txt文档的语句,txt中出现乱码?

被放逐 发布于 2008-06-21 11:00, 1677 次点击
Dim fs As New FileStream("D:/file.txt, FileMode.OpenOrCreate)
Dim sw As StreamWriter = New StreamWriter(fs)
sw.WriteLine("记录")
sw.Close()

发现如果是英文和数字就显示正常,但中文就会出现类似繁体字的乱码,怎么回事?
而且有时候会正常,有时候又不正常
4 回复
#2
vinceQ2008-06-30 12:10
这是中文编码问题.
#3
tntzwc2008-06-30 17:01
实例化类StreamWriter的时候,可以选择编码
#4
Viviwei2008-07-02 16:46
In IO operation can be encoded choice, generally GB2312, such as the code: System.Text.Encoding.GetEncoding ( "GB2312")
#5
tntzwc2008-07-03 08:39
super man
1