记事本作为数据库:写入、读取数据

 转:记事本作为数据库:写入、读取数据
using System.IO;

//写入
StreamWriter sw = new StreamWriter( @"C:\temp123.txt");
sw.WriteLine("----------------hello----------------");
sw.WriteLine("内容");
sw.WriteLine("----------------hello----------------");
sw.Flush();
sw.Close();

//读取
System.IO.StreamReader st;
st = new System.IO.StreamReader(@"C:\temp123.txt", System.Text.Encoding.UTF8);//UTF8为编码
this.textBox1.Text = st.ReadToEnd();

原文地址:https://www.cnblogs.com/qq1040991197/p/2783589.html