Reading a Rich Text File

  • Thread starter Thread starter pooba53
  • Start date Start date
P

pooba53

I have the following code that is successfully opening my *.rtf file:

If File.Exists(FilePath) Then
Try
Dim MyFileStream As New FileStream(FilePath,
FileMode.Open)
RichTextBox1.LoadFile(MyFileStream,
RichTextBoxStreamType.PlainText)
MyFileStream.Close()
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
Else
MsgBox("I'm afraid I could not find your instructions
file.")
Me.Close()
End If

Problem is, it's showing all sorts of giberish along with the text. I
thought a RichTextBox would display the file as if I was opening it in
Wordpad or some other Rich Text File viewer.

What am I missing here?

Thanks.
-Dan
 
Suggestion:

Replace RichTextBoxStreamType.PlainText with
RichTextBoxStreamType.RichText
 
Back
Top