如果它不存在,我将创建一个文本文件,然后在我向该文件添加文本后立即创建。但是,我的编译器说它正在被另一个进程使用,我认为这是因为它刚刚创建。我怎样才能解决这个问题?
代码摘录-
//If the text document doesn't exist, create it
if (!File.Exists(set.cuLocation))
{
File.CreateText(set.cuLocation);
}
//If the text file after being moved is empty, edit it to say the previous folder's name
System.IO.StreamReader objReader = new System.IO.StreamReader(set.cuLocation);
set.currentUser = objReader.ReadLine();
objReader.Close();
if (set.currentUser == null)
{
File.WriteAllText(set.cuLocation, set.each2);
}