0

I have a process that interacts with an Excel application in background, but sometimes the process has an error and the Excel Application doesn't finish correctly.

Always, when this process starts try to delete the Excel file from the hard drive.

But, when the process has an issue and I retry to run the process again, the following message shows me when I try to delete the Excel file:

"The process cannot access the file [Excel file path] because it is being used by another process."

I can not kill all processes of Excel. Then, my question is: Is there some way to know what is the process that manage this Excel? Or, Is there some way to know the process using a Try ... Catch structure?

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
MiBol
  • 1,985
  • 10
  • 37
  • 64
  • 1
    Famous duplicate for `I cant kill the Excel.exe process`: [How to properly clean up Excel interop objects in C#](http://stackoverflow.com/questions/158706/how-to-properly-clean-up-excel-interop-objects-in-c-sharp). Once you dispose Excel properly you wont get the file locks and you can verify this using ProcessExplorer. Good luck! – Jeremy Thompson Oct 22 '12 at 04:22
  • @JeremyThompson: Thanks by your suggestion, but, this is not the kind of solution that I been searching – MiBol Oct 22 '12 at 12:36
  • Can you show us the code that causes Excel to have a problem and not finish correctly. – Jeremy Thompson Oct 22 '12 at 23:08

0 Answers0