파일이 경로에 존재하지 않고 해당 경로가 존재하는 것으로 간주하고 파일이 존재하는 경우에만 파일을 만들려고합니다. 이미 존재하므로 사용자가 계속해서 앱을 종료하지 못하게합니다. 나는이 일을 시도했으나 위치를 알려줄 때 파일이 존재하지 않는다고 알려줍니다.파일이 존재하지 않는 경우에만 사용자가 지정한 경로의 파일 생성
this.path = @output;
this.path2File = @output + "\\" + type + "tobearchived.txt";
if (!Directory.Exists(path) && !File.Exists(path2File))
{
File.Create(path2File);
}
else
{
Console.WriteLine("Error: File Already Exists. Press any key to exit.");
Console.ReadKey();
Environment.Exit(0);
}
}
나는 내 논리를 엉망으로 만들었습니다. 많은 사람 – PhillipsJP