When you write this code:
string path = @"c:\temp\MyTest.txt";
// This text is added only once to the file.
if (!File.Exists(path))
{
// Create a file to write to.
string[] createText = { "Hello", "And", "Welcome" };
File.WriteAllLines(path, createText);
}
Now I want to save every line of richTextBox content to new line of .txt file like result image. I write my code as below:
private void button1_Click(object sender, EventArgs e)
{
richTextBox1.AppendText(textBox1.Text +"\n");
System.IO.File.WriteAllText(@"C:\Users\Mohammad_Taghi\Desktop\ab\a.txt", richTextBox1.Text + Environment.NewLine);
}
but,the result is