您的位置:首页 > 编程语言 > C#

C# winform写入和读取TXT文件

2014-08-28 16:06 218 查看
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;///读取
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: