for reference I have looked at Is there a way to check if a file is in use? and How to wait until File.Exists?
but I want to avoid using SystemWatcher as it seems kind of overdoing. My application is calling cmd prompt to create a file and as there is no ways for my application to know when it is finished I was thinking of using Sleep() as long as the file does not exist.
string filename = @"PathToFile\file.exe";
int counter = 0;
while(!File.Exists(filename))
{
System.Threading.Thread.Sleep(1000);
if(++counter == 60000)
{
Logger("Application timeout; app_boxed could not be created; try again");
System.Environment.Exit(0);
}
}
Somehow this code of mine does not seem to work. What could be the cause?