How to delete a file in Windows
If the computer reports that the file is open in another program
Most often, the inability to delete a file in Windows is due to the fact that it is busy with some kind of system process. The message «The action cannot be performed because this file is open in The name of the program«.
In this case, you need to close the program that uses the file and try again. If you see her window, then just click on the cross. If the utility is running in the background and you don’t know how to close it, launch the «Task Manager» (Ctrl + Shift + Esc), find it in the list, right-click on it and select «End Task».
If you cannot find the program you need in the Task Manager, try a third-party utility that unlocks files. The free app LockHunter will do. After installing it, right-click on the file and select What is locking this file? When the LockHunter window appears, click Unlock It!
Then try deleting the file again. If unsuccessful, restart your computer and try again. For complete removal from the system, do not forget to empty the trash.
If your computer says you are denied access
Sometimes you can’t delete a file because your account doesn’t have permission to do so. In such cases, Windows reports that access is denied. To solve the problem, you need to change the owner of the file. In the process, you may need a login and password from the PC administrator account.
To change permissions, right-click on the file and go to «Properties» → «Security» → «Advanced». Next to the «Owner» item, click «Change», then «Advanced» and «Search». Select the current account from the list and click OK.
After that, you will most likely be able to delete the file in the usual way. If it doesn’t work, try restarting your computer and try again.
If nothing helps
In hopeless situations, you can try to archive a non-removable file with subsequent deletion, and then the archiver will do everything for you. For these purposes, any application for working with archives is suitable. For example, free 7Zip.
Run the archiver, find the desired file and, having selected it, click the «Add» button on the toolbar. It remains only to check the option «Delete files after compression» and click OK. The element that cannot be deleted will be destroyed automatically, and you can send the created archive to the trash yourself without any problems.
However, there is another trick. The point is to force Windows to overwrite the file with a new one, giving it the same name.
To do this, open the standard Notepad and create a new text document, you can even empty it. Then go to the menu «File» → «Save As …», and then to the folder with the item that cannot be deleted. Next, select the «All files» option, click on the problematic file to select the same name and resave it, agreeing to replace it. After that, you can easily delete the changed document.
How to delete a file in macOS
If the Mac says the file is in use
To get started, manually close the applications in which this file was involved, and try to erase it again. If you see a program icon in the dock, right-click on it while holding Option and select Force Quit.
If the application does not appear in the dock, search Spotlight for System Monitor, open it, and then search for the program in the list or through the built-in search and click the cross on the toolbar to finish.
If that doesn’t work, enter Safe Mode. To do this, turn off your Mac completely, and then turn it on without releasing the Shift key (Intel processors). On devices with Apple chips, hold the power button, select the boot volume and hold Shift to continue in recovery mode. Try moving the file to the trash and emptying it, then restart your computer to return to normal mode.
If the file cannot be deleted for other reasons
Another solution is to delete through the console, bypassing the trash and all system confirmations. To do this, launch the «Terminal» via Spotlight or from the «Programs» → «Utilities» folder, copy and paste the command sudo rm -r. Put a space, and then drag the file into the window, press Enter and enter the administrator password.
The file may not be deleted due to disk errors. Therefore, open Finder, launch «Disk Utility» from the «Programs» → «Utilities» folder and check the disk on which the item of interest is located in it with the «First Aid» service.
Once verified, restart your Mac and try deleting the file.
This article was first published in December 2017. In September 2022, we updated the text.
Read also 💻💿📁