编程语言
首页 > 编程语言> > c#文件的读写

c#文件的读写

作者:互联网

//写
using (FileStream fs = File.Create(filename))
{
  byte[] info = new UTF8Encoding(true).GetBytes("This is some text in the file.");
  fs.Write(info, 0, info.Length);
}

//读
using (StreamReader sr = File.OpenText(filename))
{
  string s = "";
  while ((s = sr.ReadLine()) != null)
  {
    DisplayAlert("read", s, "");
  }
}

标签:info,文件,fs,c#,sr,读写,filename,File,using
来源: https://www.cnblogs.com/blanc/p/16087369.html