How do I programmatically force the deletion of files that are locked by the operating system or any other program with C/C++? The functionality should be similar to the software "Unlocker" at http://ccollomb.free.fr/unlocker.
Open the Start menu, then the File Explorer and find the formerly locked file. Remove the file. Click the previously locked file, then the “Home” tab, and “Delete” in the toolbar. Or, you may select the file by clicking on it and then pressing the “Delete” key.
Use Shift + Delete to Force Delete File/Folder. You can select the target file or folder and press Shift + Delete keyboard shortcut to delete the file/folder permanently. This file deletion method won't pass the Recycle Bin.
In the command window, type the DEL /F file name command and press Enter to force delete the file that is in use.
Open Task Manager by pressing Ctrl + Shift + Esc key. In there, find the process or program that is using the file. Right-click on it and choose End task from the to close the program. Once closed, go ahead and see if you're able to delete the file or folder.
Look this sample.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With