4
Answers

Closing a file opened by a process

I run and stop a process with

Process pr = Process.Start("program.exe") ;
pr.WaitForExit(500) ;
if ( ! pr.HasExited )
   pr.Kill();

The problem is that "program.exe" opens a file (for example: test.txt) and with "pr.Kill(); " test.txt remains opened. How can I close this file?
Answers (4)