Nikunj Satasiya

Nikunj Satasiya

  • 193
  • 10k
  • 3.6m

How to find out which windows process is using a file?

Jan 21 2020 2:43 PM
I've seen several answers about using Handle or Process Monitor, but I would like to be able to find out in my code (C#) which process is locking a file.
 
Ex. I open two files like test.xlsx and test_1.xlsx and I want to close the only process of text.xlsx, but right whatever I find that close only my last open excel file or both files. This only example, I have so many files of different types and I need to close from them only several.
 
I try to "Handle" but it needs administrative rights, and restart manager also not provide exact process id which I use from different examples.
 
Please help me...!

Answers (1)