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.
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);
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,TeodorSoftware DeveloperInfragisticswww.infragistics.com/support
Hello Teodor,
Thank you for your time. Now, works fine.