Detect orphan files after program crash

G

Gunnar

Are there any way of detecting that a program have crashed and left an
orphan file?
I have tried with the filesystemwatcher, but that didn't work.

Maybe I can use a polling strategy and keep polling the file and check if it
is locked. But can I do this without trying to open the file and catch
exeption.
Any suggestions are welcome?

Regards
Gunnar
 
I

Ignacio Machin \( .NET/ C# MVP \)

Hi,


Gunnar said:
Are there any way of detecting that a program have crashed and left an
orphan file?

What you mean with an orphan file?
Maybe I can use a polling strategy and keep polling the file and check if
it is locked. But can I do this without trying to open the file and catch
exeption.

If the file is locked then the program is still running.

You can check the process list to see if a program is running or not.

And no, AFAIK the only way to really know if you can open a file is trying
to open it and handling the exception
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top