我希望使用此方法明确文本文件
private void writeTextFile(string filePath, string text)
{
if (!File.Exists(filePath))
{
File.Create(filePath).Close();
}
using (StreamWriter tw = new StreamWriter(filePath))
{
File.WriteAllText(filePath,"");
tw.WriteLine(text);
tw.Close();
}
}
Run Code Online (Sandbox Code Playgroud)
但我得到这个错误
The process cannot access the file because it is being used by another process.
Run Code Online (Sandbox Code Playgroud)
但这不能在任何地方打开,
请帮我谢谢