Results 1 to 3 of 3

Thread: [RESOLVED] Saving RTF in XML file

  1. #1

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    32

    Resolved [RESOLVED] Saving RTF in XML file

    Hello,
    I am working on a note taking application. I have got a treeview and a richtextbox. On the treeview note captions are organized in a hierarchy. When a tree node is clicked related note details are displayed in the richtextbox. I use an xml file to save and load the treeview state (including nodes, expand collapse state, image index etc). I want to include all the note details in this xml file as well. But I don’t know how to save richtextformat into an xml file. If someone helps me I will be very happy. Thank you.

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367

    Re: Saving RTF in XML file

    You should be able to save it just like any other text. So when you save it, save the .RTF and when you load it, set the .RTF to the value from the XML. You may need to wrap the data in CDATA tags within the XML, in case there are any special characters in the rtf string.

  3. #3

    Thread Starter
    Member
    Join Date
    Feb 2010
    Posts
    32

    Re: Saving RTF in XML file

    Negative0, thank you very much for your reply. After your post, I realized that I can save richtext just like any other text. First, I use savefile method of richtextbox and I save a temporary file as rtf. Then I open it by using streamreader and convert it to regular string. Then I put it to xml file. When I want to load the file, I get the text by using streamreader. I write it to a temporary file by using stream writer, as rtf. Finally I use the LoadFile method of the richtextbox to load file in rich text box. I guess that was what you were saying in your post. Currently my problem has been solved thanks to your reply.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width