I am trying to write text to a text file. I have googled a lot and tried a lot. I can get it to write to a file, that's not a problem. However it does not include the new line character apparently. I have a Windows form. It has a single rich textbox on it. The user types in whatever they want, and I pass that text to the variable "plainText". I want to then save whatever is in that variable to a text file. Here is what I currently have.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.IO;
namespace Keep_it_Private
{
public partial class Form1 : Form
{
string plainText = null;
string path = @"C:\Users\Brannon\Desktop\temp.txt";
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
plainText = richTextBox1.Text;
File.WriteAllText(path, plainText);
}
}
}
I am currently using Visual Studios 2012 and Windows 10.