方法1:
写文件
StreamWriter sw = new StreamWriter(fileName); sw.Write(textBox1.Text); sw.Close();
读文件
StreamReader sr = new StreamReader(fileName); textBox1.Text = sw.ReadToEnd(); sr.Close();
方法2:
读:
TextBox1.Text=File.ReadAllText("d:/b.txt",Encoding.Default);
写:
File.WriteAllText(“d:/a.txt”, TextBox1.Text, Encoding.Default);