图片显示了下面文本的显示方式:-
下面是更新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)
最佳答案
这是一个关于错误编码的问题,请使用指定文本编码的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
关于.net - RichTextBox 不显示 ' 并显示一个菱形,而不是里面有一个问号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36114108/