Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
200
Import/Export data from/to MemoryStream
posted

Hello,

I'd like to import/export text formatted data from/to XamRichTextEditor using MemoryStream. 

I did the following for import, but text data wasn't displayed in  XamRichTextEditor:

using (MemoryStream ms = new MemoryStream())
{
  using (StreamWriter sr = new StreamWriter(ms))
  {
    string text = "Test data format.";
    sr.WriteLine(text);
    sr.Flush();

    RichTextDocument rtd = new RichTextDocument();
    rtd.LoadFromPlainText(ms);
    XamRichTextEditor1.Document = rtd;

  }

}

Could you provide me any sample how to import/export text formatted data from/to XamRichTextEditor using MemoryStream?

Thank you.

Alexander.

Parents
  • 1530
    Verified Answer
    posted

    Hello Alexander,

     

    Thank for your post.  I have been looking into it and what you are missing is to set the position to the beginning of the stream in order to read the data from the stream before loading it. You can do this by

     // Set the position to the beginning of the stream.

                        ms.Seek(0, SeekOrigin.Begin);
                        RTE.Document.LoadFromPlainText(ms);

     

    I have attached a sample demonstrating how to import/export data from/to XamRichTextEditor. Please review it and if you have any more questions do not hesitate to ask.

     

    Sincerely,
    Teodor
    Software Developer
    Infragistics
    www.infragistics.com/support

    RTE_Load_Save_Dialogs.zip
Reply Children