At some point you will encounter a folder or file on your Windows Desktop that you’re unable to delete. Many times you will get an error prompt that says “An unexpected error is keeping you from deleting the folder 0x8007016A” or another random response and code similar to this one like “File no longer exists 0x0000008”. This can happen when a file is open in another application or process, Windows puts the file into a locked state, and you can’t delete, modify, or move it to another location. Usually, after the file is no longer in use, the application will unlock it automatically, but that’s not always the case. There are other case scenarios where the file is not open in another application or process and claims not to exist at all because it was deleted, what you may call phantom files and folders. There are a lot of methods and programs that try to help resolve this issue but over the years I have found these steps to work 90% of the time.
Click on your start button and in the search bar search for Command Prompt or CMD for short. Once you have located the application you will want to Right Click on the application and select “Run as administrator“. It should look something similar to this depending on which Windows version you are running, this is on Windows 11.
Once you have successfully run the Command Prompt in Administrator mode you should be presented with a window that looks like this.
Now that you have your command prompt window you will want to use the following command to remove the file or folder. But to do so you will need to also have the file or folder path.
To remove a file you can use this command.
DEL /F /Q /A “File Path”
To remove a folder and its contents use this command.
rmdir /s /q “folder_path”
you can also use this command RD /S /Q “folder_path”
To acquire your file or folder path right click on the file or folder and select “Copy as Path”. If this is not an option for you just select the folder or file you want to remove and use the keyboard shortcut “Ctrl + Shift + C” to copy the path. Once you have your file path you can paste it into the command prompt using the keyboard shortcut “Ctrl + P”. It should include the quote brackets “” but if it does not make sure to include them as referenced in the commands.
Once you are done it should look like this. Go ahead and hit the enter button on your keyboard to run the command and it should have removed your file or folder.
If you prefer to use PowerShell, follow the same steps above, search for PowerShell under your start button. Right Click on the application and select “Run as administrator”. Use the following power shell command to remove the file or folder.
remove-Item -path “File Path” -force
If none of these options worked for you then you will find many types of other solutions on Google using various free software and other methods you can try.