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

Asked

Viewed 146 times

0

Hello, I would like to know if there is any way inside VB.NET (Use Visual Studio 2017 [Winform] ) to delete a file being used by another process, in case, forcibly delete the file, even if it may harm the process that was using it, Please, does anyone know any way to do that? I need a lot for a new project.

1 answer

0

The operating system blocks the file and you won’t be able to change it.

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

You have some alternatives:

When it’s on the same computer:

  1. Finish the process that is using the file. (If different users, the user must have permission to do so)

When it is shared file:

  1. Try renaming the file. (Usually works on Windows Server, in OS clients I can’t confirm this)

  2. Stop the windows service Server, which interrupts sharing, deleting the file, and then starting the service again. (By stopping the Server the service Pesquisador de computadores will also be stopped. Remember to initialize both. I do not think this alternative is recommended, because it can cause unwanted effects to users, perhaps it is necessary technical support intervention)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.