텍스트 파일이 없으면 텍스트 파일을 작성하고 텍스트를 추가하는 직후입니다. 그러나 제 컴파일러는 다른 프로세스에서 사용하고 있다고 말합니다.이 프로세스는 방금 생성 된 것으로 가정합니다. 이 문제를 어떻게 해결할 수 있습니까?작성한 후 텍스트 파일 편집
코드
//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);
}
해당 스트림을 닫으려면 어떻게해야합니까? – TheUnrealMegashark
@TheUnrealMegashark 설명서를 읽는 것이 좋습니다. 여기에있는 예제는 어떻게하는지 보여줍니다. –
@ TheUnrealMegashark, 그냥 끝에 .Close()를 추가하십시오. – gunr2171