Click here to Skip to main content
14,826,846 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I tried using file stream to write to File from Richtextbox. it works okay but the new lines are not working in the saved file.
Posted
Comments
MuhammadUSman1 24-Nov-14 6:07am
   
What do you mean new lines are not working in the saved file?
Midhun Thadathil 24-Nov-14 6:47am
   
The text in the output file[.txt] is in just one line.
BillWoodruff 24-Nov-14 7:44am
   
How do you want the file you create to appear ? Note that if the user has word-wrap turned-on in the RichTextBox (the default), there is no tag in the RTF that indicates where word-wrap occurs.

If you tell us the output format you want for what appears in the RTF now as hard (not word-wrapped) line breaks (the user hit the Enter Key), we can probably help.

Rich text boxes don't use newlines in the same way that "text files" do: they work on "paragraphs" of information which split into new lines based largely on the size of the box, not the text they contain. This doesn't translate into "text friendly" information because if it did, when you reloaded the RTB the lines would be "fixed" and wrong if the RTB size changed.

Save it as Rich Text, and any Rich Text editor (Word for example) should be able to read it and paginate it nicely. Text files aren't meant for that!
   
Comments
BillWoodruff 24-Nov-14 7:39am
   
Click-Drag-Copying the Rtf content of a RichTextBox, and pasting it into a TextBox, will transform \par codes into NewLines.
Try any text editor e.g. notepad++ , wordpad except notepad I am sure you will see those new line.I think Environment.NewLine can handle this.
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900