C#对文本进行简单的写入

 string path = System.IO.Directory.GetCurrentDirectory();//相对路径
 FileInfo fi = new FileInfo(path + @"Dataunity.txt");
  ////如果该文件存在需要删除重新写入
  if (fi.Exists)
 {
   fi.Delete(); 
  }
  StreamWriter sw = new StreamWriter(path + @"DataStreamingAssetsunity.txt");
   sw.WriteLine(需要写入的内容方法);
   sw.Close();
   MessageBox.Show("写入成功! ^-^ ", "TaoHu", MessageBoxButtons.OK, MessageBoxIcon.None);
 
原文地址:https://www.cnblogs.com/htwzl/p/7351824.html