0

Hi there how is it going?! I was looking for a way to close / unlock / rename a file that's in use by a process withouth killing that process in vb.net?!

Example: I need to update some .bpl which may be used when i start my update. To do that i try to delete the file or move it (or whatever allows me to put the new .bpl into the folder).

Clearly if the file is in use i get an exception which says that the access to that file is denied because the file is in use by another process. Assuming that i can't shut down the entire process, is there any way to achieve it from vb.net instead of using Handle.exe?

Madalin Mad
  • 129
  • 1
  • 3
  • 10
  • try reading/writing file without locking it. https://stackoverflow.com/questions/3448230/how-can-i-read-a-text-file-without-locking-it – Avinash Nov 28 '18 at 12:31
  • If it's your application that's locking the file: Yes, see the link above. If it's an external application locking the file: Unlikely without handle.exe as you'd have to reinvent its way of doing this, which would require quite a bit of P/Invoking. – Visual Vincent Nov 28 '18 at 17:11

1 Answers1

-1

After many attemps i realize that windows doesn't allow you to close (or do any other task) a file which is actually locked by another process. Suddenly i remembered of a strange behavior that afflicts services .exe (like service_name.exe files).

The behavior i'm talking about regards the chance of renaming the file even if the file is being used by another process. I found out that You can apply the same concept to some files like .bpl files so here's the solution.

I really hope it helps, thansk.

Madalin Mad
  • 129
  • 1
  • 3
  • 10