VB.NET - How to delete files being used by another process

0
Hello, I would like to know if there is any way inside VB.NET (I use Visual Studio 2017 [WinForm]) to delete a file being used by another process, in this case, forcibly deleting the file, even if it could harm the process that was using it, please, does anyone know any way to do this? I'm really in need of a new project.

    
asked by anonymous 07.04.2018 / 05:07

1 answer

0

The operating system blocks the file and you will not be able to change it.

This type of situation usually occurs when the file is being used by another user, even on the same computer, or on another computer by file sharing.

You have some alternatives:

  

When on the same computer:

  • End the process that is using the file. (If different users, the user must be allowed to do so)
  •   

    When it's a shared file:

  • Attempt to rename the file. (Normally it works on Windows Server, in OS clients I can not confirm this)

  • Stop the windows Server service, which stops sharing, deletes the file, and then starts the service again.

  • 07.04.2018 / 14:06