In Windows, you cannot delete a file or a folder if some program or the OS itself is using it, not even forcefully. Unfortunately, it will also not inform you which application is using the file you are trying to delete. You will only see a message that the file is open in another program but will not be able to move or manipulate it in any way.

This helps ensure that the program using the file does not crash, there is no data loss, and the file does not become unreadable. Even in such cases, there are still certain steps you can take to fix the problem. Here are a few methods that can help you recover access to the file so you can move or delete it as you wish.

Method 1: Using Microsoft PowerToys

  1. Search for Microsoft PowerToys in the Microsoft Store and click on the 'Install' button to download it.
  1. Once PowerToys is installed, it should open automatically. If that does not happen, you can launch it from the Start menu. When it opens, click on the toggle next to 'Enable File Locksmith' to turn it on.
  1. Now, if you cannot use, move, or delete a file because it is being used by another program, right-click on it and click on 'Unlock with File Locksmith'. This will show you the applications that are using the file.
  1. If you want, you can click on the 'End task' button to close the program that is using the file. Once the program closes, you can move or delete the file as you wish.
Note: Before closing a program, check that it is safe to do so. If you end a program that is reading or writing a file, the file can get damaged. Make sure to create a backup of the file to avoid problems.

Method 2: With Resource Monitor

Windows has a built-in resource monitor that lets you see which applications are using the most resources. It can also let you know whether a program is using a particular file.

  1. Open the Start menu, type Resource Monitor, and click on 'Run as administrator'.
  1. Once the Resource Monitor opens up, click on the 'CPU' tab at the top and then on 'Associated Handles'.
  1. You can now type the name of the file you want to check in the search box. When you do so, all processes using the file will be visible in the 'Image' column.
  1. You can end any process using the file by right-clicking on it and then clicking on 'End process'.

Method 3: Using Handle and Powershell

Handle is a program that lets you view which program is using a directory or a file. You can download it from the official link or use Process Explorer, its GUI-based version from this link.

  1. Once you've downloaded Handle, open a Powershell window where it is located and type ./handle.exe -a -u "PATH TO LOCKED FILE". The -a option provides information about the application using the file in question, while -u lets you know who owns the file.
  1. You can add the handle to your system path by copying it from scripts to your programs folder and even end the process completely from the script.

Things to know

  • It is always better to wait for a program to finish reading or writing to the file rather than trying to end the process that is using the file.
  • Also, having a backup of your files can help you avoid problems in case you end a process and a file gets damaged and becomes unusable.
  • You should also check that you have ownership rights for the file you want to use. Many times Windows does not let you move or delete a file if you do not have the required permissions.
  • If nothing else works, you can reboot your PC, which will force close all open programs, allowing you to use the file.