RichTextBox 不显示 ' 而是显示一个菱形,而不是里面有一个问号
RichTextBox does not display ' and shows up a diamond instead with a question mark inside it
图片显示了下面文字的显示方式:-
下面是更新 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
图片显示了下面文字的显示方式:-
下面是更新 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