用readalltext怎么在文本框中,中文显示的是乱码
我是个初学者,下面是代码(按照书上的来做的)。。。
但当我打开TEXT文本后,中文显示全是"口",英文与数字能正常显示。。难道是VS2008英文版的缘故吗??
Public Class dialogs
Private strfilename As String
Private Sub btnopen_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnopen.Click
With OpenFileDialog1
.Filter = "Text files(*.txt)|*.txt|All files(*.*)|*.*"
.FilterIndex = 1
.Title = "DEMO"
End With
If OpenFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Dim fileContents As String
strfilename = OpenFileDialog1.FileName
fileContents = My.Computer.FileSystem.ReadAllText(strfilename)
txtfile.Text = fileContents
End If
End Sub
End Class