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 on 2014-08-28 16:06  努力实现目标  阅读(55927)  评论(1编辑  收藏  举报