I have a System.Windows.Controls.RichTextBox control and trying to load rtf files using below code:
Public Sub LoadRTFDocument(fileName As String) Dim range As TextRange Dim fStream As System.IO.FileStream If (System.IO.File.Exists(fileName)) Then range = New TextRange(rtf.Document.ContentStart, rtf.Document.ContentEnd) fStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.ReadWrite) range.Load(fStream, System.Windows.DataFormats.Rtf) fStream.Close() End If End Sub
I got some RTF files where the hyperlinks are not placed correctly. While trying to load these files into my control I get below error:
"Unrecognized structure in data format 'Rich Text Format' Parameter name: stream"
But when I double click the file, it opens in ms word/wordpad with an error displayed at the hyperlink "Error! Hyperlink reference not valid.".
My requirement is to suppress the error and load the file in my control (just like the MSWORD opens it) anyhow even if it displays the error with the hyperlinks.
I need to resolve the error I get while loading these files anyhow. This is very urgent. It will be highly appreciated if someone can help me out with this.
A sample copy of the rtf file is located at
Thanks in advance.