title: c# how to detect if file is open in another process
body: <p>I have seen these questions, and I am not asking the same question:<br>
  <a href="https://stackoverflow.com/questions/876473/is-there-a-way-to-check-if-a-file-is-in-use">Is there a way to check if a file is in use?</a><br>
  and<br>
  <a href="https://stackoverflow.com/questions/2340607/how-to-check-file-in-use-in-c-sharp">How to check if file is in use in c#?</a></p>
  
  <p>I am asking the question, how to detect if file is open in another process.  It's the same question those other guys asked, but the answers they got tell them to see if they can get exclusive lock on the file, in order to imply the file being open in another process.  I do not wish to get exclusive lock on a file, because I don't want to potentially interfere with the operation of the other processes.</p>
  
  <p>Also, different OSes might behave differently - some OSes might support things like filesystem-level or block-level snapshots or shadow copies, which might allow you to get exclusive lock on a file, <em>even if</em> some other process has the file open for reading.</p>
  
  <p>One person in the other questions said you can test all the open file handles in the system.  Is that the only way?  And if so, how would one go about doing it in C#?  I don't see any obvious native .Net class to browse all the open file handles in the system.</p>