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;///读取

posted @ 2016-12-14 13:56  Mr.Jiang.K  阅读(1050)  评论(0编辑  收藏  举报