Jump to content

Check out our Community Blogs

Register and join over 40,000 other developers!

Recent Status Updates

View All Updates

- - - - -

Using StreamWriter to put text from RichTextBox to .txt file

streamwriter stream

  • Please log in to reply
1 reply to this topic

#1 biscuits


    CC Lurker

  • Just Joined
  • Pip
  • 8 posts

Posted 23 July 2010 - 08:41 AM

Ok I need to write text that is in a RichTextBox into my text file so far I have managed to achieve this, BUT when it writes all the text to the .txt file it puts it all on one line, I need it to put the text on separate lines inside the .txt file. Here's my code so far:

            StreamWriter writer2 = new StreamWriter(@"C:\Users\Alex\Documents\Visual Studio 2010\Projects\MealDeliverySystem\orders.txt");

Posted Image
this is what my form looks like, notice how each bit of text goes on a separate line? thats how I want it to look inside my .txt file.

Any help is much appreciated, Thanks.
  • 0

#2 anotheruser


    CC Regular

  • Just Joined
  • PipPipPip
  • 44 posts

Posted 23 July 2010 - 10:00 AM

I don't know what causes that problem but you could split the text into separate strings with "\n" as the parameter that signals where to make a cut. Then just cycle through the results and use writer2.WriteLine(i) on each of them.
  • 0

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download