1. Set RichTextBox to run line breaks
Set the Acceptreturn property to True
2. Save RichTextBox content to file //path for full save path name private void Savertffile (string path) {FileStream fs = New FileStream (path, filemode.create); TextRange range; Range = new TextRange (YourRichTextBoxName.Document.ContentStart, yourRichTextBoxName.Document.ContentEnd); Range. Save (FS, dataformats.rtf);//dataformats.xaml or Dataformats.xamlpackage fs. Close (); }
3. Load the saved RTF file into the RichTextBox display
Also use the TextRange class, through the Load method
//path is the full load file path name private void Loadrtffile (string path) {FileStream fs = file. Open (Path,filemode.open); TextRange TextRange = new TextRange (YourRichTextBoxName.Document.ContentStart, YOURRICHTEXTBOXNAME.DOCUMENT.CONTENTEND); Textrange.load (FS,DATAFORMATS.RTF); Fs. Close (); }