Reading a Rich Text File

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • pooba53

    Reading a Rich Text File

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

    If File.Exists(Fil ePath) Then
    Try
    Dim MyFileStream As New FileStream(File Path,
    FileMode.Open)
    RichTextBox1.Lo adFile(MyFileSt ream,
    RichTextBoxStre amType.PlainTex t)
    MyFileStream.Cl ose()
    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

  • Karel   H o n i n g s

    #2
    Re: Reading a Rich Text File

    Suggestion:

    Replace RichTextBoxStre amType.PlainTex t with
    RichTextBoxStre amType.RichText

    "pooba53" <pooba53@gmail. comschreef in bericht
    news:1176931588 .697678.218570@ o5g2000hsb.goog legroups.com...
    I have the following code that is successfully opening my *.rtf file:
    >
    If File.Exists(Fil ePath) Then
    Try
    Dim MyFileStream As New FileStream(File Path,
    FileMode.Open)
    RichTextBox1.Lo adFile(MyFileSt ream,
    RichTextBoxStre amType.PlainTex t)
    MyFileStream.Cl ose()
    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
    >

    Comment

    • pooba53

      #3
      Re: Reading a Rich Text File

      Thanks, Karel!

      Works like a charm ;-)

      I really appreciate the help.
      -Dan

      On Apr 19, 7:07 am, "Karel H o n i n g s" <geen_s...@acco unt.nl>
      wrote:
      Suggestion:
      >
      Replace RichTextBoxStre amType.PlainTex t with
      RichTextBoxStre amType.RichText
      >
      "pooba53" <poob...@gmail. comschreef in berichtnews:117 6931588.697678. 218570@o5g2000h sb.googlegroups .com...
      >
      I have the following code that is successfully opening my *.rtf file:
      >
      If File.Exists(Fil ePath) Then
      Try
      Dim MyFileStream As New FileStream(File Path,
      FileMode.Open)
      RichTextBox1.Lo adFile(MyFileSt ream,
      RichTextBoxStre amType.PlainTex t)
      MyFileStream.Cl ose()
      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

      Comment

      Working...