首页 > 技术文章 > C# winform写入和读取TXT文件

hfzsjz 2014-08-28 16:06 原文

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

推荐阅读