2

Is there a way to get the program that is locking a file, in vb 2005?

For instance, when I try to open a file that is already opened by another program, can I get the name of the process/program that has locked this file?

UnkwnTech
  • 88,102
  • 65
  • 184
  • 229
Jim
  • 601
  • 6
  • 17
  • I've gotta say this is not a duplicate the previously liked question is about c# this is VB. – UnkwnTech Jun 01 '09 at 10:57
  • However there is a relevant answer there, although it only works for Dlls http://stackoverflow.com/questions/317071/how-do-i-find-out-which-process-is-locking-a-file-c/317209#317209 – UnkwnTech Jun 01 '09 at 10:58

1 Answers1

3

System Internals has a tool called Handle that you can use. It tells you which program has what file and/or directory open. It is a console application. You can pipe its output to a text file and then simply open that text file and search for the file you're looking for. Then you can see which process has it open.

c:\handle > output.txt
Mehmet Aras
  • 5,284
  • 1
  • 25
  • 32
  • You can also install ProcessExplorer from the same SysInternals Suite ( download at http://download.sysinternals.com/Files/SysinternalsSuite.zip ) and look for handles in the search box. This way you can even kill the offending process (or thread if you like living on the edge). But handle is a lot faster. – Yann Schwartz Jun 01 '09 at 14:30