using (FileStream fs = new FileStream("text.txt", FileMode.Append, FileAccess.Write))
using (StreamWriter sw = new StreamWriter(fs))
{
string data = "asfsa";
sw.WriteLine(data);
sw.Close();
}
以某种方式有一个程序在没有文本文件的情况下使用它,这意味着我无法写入数据,并且程序崩溃了。我可以做什么?谢谢。
从系统中删除系统'System.IO.IOException'的所有内容,然后再进行任何控制。该进程无法访问文件'text.txt',因为它正在被另一个进程使用。
静态StreamWriter file2 = new StreamWriter(“ hits.txt”,true);file2.WriteLine(data);