tamaro
July 25th, 2007, 07:38 AM
From within my program, when the user clicks the Run button, I call a console application like this:
Process p = new System.Diagnostics.Process();
ProcessStartInfo psI = new ProcessStartInfo("cmd");
p.Start();
sw = p.StandardInput;
sw.WriteLine(strStartCommand);
The console application deletes the old output file and creates a new one every time it runs.
Depending on user input, sometimes it's run directly through the code above and sometimes through a delegate function that calls the above code.
Whenever the direct path is used after the program has already been run once before, i get an exception of type 'System.IO.IOException' (The process cannot access the file "D:\...." because it is being used by another process) when trying to delete the old output file using:
File.Delete(strOutputFile);
What's the difference between the two ways of running the code and why do I get that exception??
Thanks.
Process p = new System.Diagnostics.Process();
ProcessStartInfo psI = new ProcessStartInfo("cmd");
p.Start();
sw = p.StandardInput;
sw.WriteLine(strStartCommand);
The console application deletes the old output file and creates a new one every time it runs.
Depending on user input, sometimes it's run directly through the code above and sometimes through a delegate function that calls the above code.
Whenever the direct path is used after the program has already been run once before, i get an exception of type 'System.IO.IOException' (The process cannot access the file "D:\...." because it is being used by another process) when trying to delete the old output file using:
File.Delete(strOutputFile);
What's the difference between the two ways of running the code and why do I get that exception??
Thanks.