C# .Net – Save Text Box Content To TXT File

A simple way to store the contents of a text box control to a local .txt file

1
2
3
4
5
6
7
8
//Use StreamWriter class.
StreamWriter sw = new StreamWriter("E:\\test.txt");
 
//Use write method to write the text
sw.Write(textBox1.Text);
 
//always close your stream
sw.Close();