110,545
社区成员
发帖
与我相关
我的任务
分享
//读取
public void Read(string path)
{
StreamReader sr = new StreamReader();
string line ;
line = sr.ReadLine();
while (line != null)
{
Console.WriteLine(line.ToString());
}
}
//写入
public void Write(string path,string context)
{
FileStream fs = new FileStream(path,FileMode.Create);
byte[] data = System.Text.Encoding.Default.GetBytes(context);
fs.Write(data,0,data.length);
fs.Flush();
fs.Close();
}