I suppose you could iterate through all the processes on the machine and
find out which files they have handles to. This is the same as using
ProcessExplorer (www.sysinternals.com) and using it to search for a
filename.
Hmmm.... I can see System.Diagnostics.Process.HandleCount but not a way to
get the handles.
If you want to check if the file is exclusively locked, open a 'FileStream'
with 'FileShare.None' and 'FileAccess.ReadWrite', and catch the exception
which occurs if the file cannot be opened that way. Note that this will
only work if the application currently dealing with the file actually locked
the file.
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.