mike

mike

  • NA
  • 25
  • 0

Process.Exited broken?

Jul 1 2010 10:17 AM

Hello,
Im using the following code to launch an 'attachment' from my program and attach the Exited event handler to it so i know when it has been closed.  This way i can then delete the temporary file that i had to create  (the attachment is a byte array until they choose to open it).
 

openedFile = new System.Diagnostics.Process();
openedFile.EnableRaisingEvents =
true;
openedFile.StartInfo =
new System.Diagnostics.ProcessStartInfo(tempPath);
openedFile.Exited +=
new EventHandler(openedFile_Exited);
openedFile.Start();

My issue is it doesn't fire all the time. If its a .txt and opens in notepad, the event fires fine.  If its an .xls and opens in excel, the event is not fired.  Why would this be?  Is there perhaps a better way of deleting a temporary file? 
Any help would be appriciated!

Answers (1)