Saving and recalling RTF Data

I have a textarea object filled with styled text (different text colors and font sizes).

Now I want to save it to a file. According to the language reference this can be done by the following lines:

Dim f as FolderItem=GetSaveFolderItem(TextTypes.TextRtf,“TestSaveRTF”)
If f <> nil then
Dim s as TextOutputStream=TextOutputStream.Create(f)
s.Write TextArea1.StyledText.RTFData
s = nil
End if

Next I want to retrieve the text from the file and load it back to my textarea object. But I can’t find example code in the language reference that is able to to this.

Can you help me?


just read and put back in TextArea1.StyledText.RTFData.
And better use binarystream.

Do you have example code for doing this or could you tell me where I can find it?

You would pretty much do it in the opposite order:

dim f as folder = GetOpenFolderItem(TextTypes.TextRtf) if f = nil then return Dim tis as TextInputStream = TextInputStream.Open(f) dim s as string = tis.readall TextArea1.StyledText.RTFData = s

Thank you Bob for the tip, I’ll try it.