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, "");
  }
}

posted @ 2022-04-01 15:52  汪洪辉  阅读(125)  评论(0)    收藏  举报