Click here to Skip to main content
15,897,371 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi all,

I have a richtextbox with some lines of text.
I tried with some logic to save that contents to notepad,
but it saves all the contents in one line.

Can anyone give me code logic for saving the richtextbox contents to notepad
line by line?

Regards,
Mohana.
Posted
Comments
OriginalGriff 4-Jun-12 2:18am    
Show us the code fragment you used to save the content: we need to know what you are doing so far.

Notepad will save plain text data.
but RTB generates the HTML data. while saving the notepad save with extension as ".htm" then i think you can see the data exactly what it has in RTB.
 
Share this answer
 
Hello Priya you can use this..
C#
File.AppendAllText("MyNotepad.txt", richTextBox1.Text.Replace("\n",Environment.NewLine),Encoding.Unicode);
 
Share this answer
 
v4
u use to getting line in array. like that

C#
string[] str = richTextBox1.Text.Split('\n');

it will return lines in this array.
 
Share this answer
 
Comments
Prosan 4-Jun-12 7:31am    
what's happen. is this not solving your problem. i have checked it. it is working. if ur problem has solved by this than accept the answer and upvote it.

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