winform 写入和读取TXT文件

C# winform写入和读取TXT文件

string str;
str=this.textBox1.Text;
StreamWriter sw = new StreamWriter(Application.StartupPath +"\txtwriter.txt", false);
sw.WriteLine(str);
sw.Close();//写入

string str;
StreamReader sr = new StreamReader(Application.StartupPath +"\txtreader.txt", false);
str = sr.ReadLine().ToString();
sr.Close();
this.textBox1.Text = str;///读取

原文地址:https://www.cnblogs.com/kunEssay/p/6179024.html