Reading a Rich Text File

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
 
K

Karel H o n i n g s

Suggestion:

Replace RichTextBoxStreamType.PlainText with
RichTextBoxStreamType.RichText
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top