图片显示了下面的文字: -
以下是更新RichTextBox的代码
If File.Exists(C_Drive + "\compu\update.txt") Then
Dim sr As StreamReader = New StreamReader(C_Drive + "\compu\update.txt")
' Read and display the lines from the file until the end
' of the file is reached.
RichTextBox1.Text = RichTextBox1.Text + sr.ReadToEnd
sr.Close()
End If
RichTextBox1.Select(0, 0)
答案 0 :(得分:2)
这是一个关于错误编码的问题,请使用指定文本编码的StreamReader
重载:
您需要确保使用正确的编码,与文本文件编码相同。
按照您提供的代码示例:
Dim textfile As New FileInfo(String.Format("{0}\compu\update.txt", C_Drive))
If textfile.Exists() Then
Using sr As New StreamReader(textfile.FullName, Encoding.UTF8)
RichTextBox1.Append(sr.ReadToEnd())
End Using
End If