I would like to know if a file is open by any process (including the caller) There are a number of suggestions already posted, which tend to revolve around trying to open the file exclusively and catching the exception.
This has not proven to be a fool-proof method in my instance. I beleive in my specific situation I can get by with scanning the names all open handles of type File of all running processes.
I don't think that you can solve this problem simply with .NET and P/Invoke. You will need to access low-level functionality. See the solution posted by AdaraCD in this thread in another forum which is using the driver development kit (DDK):