Attempting to delete a folder in Explorer failed with error 0x80070091: the directory is not empty
. del
from admin command prompt gave a 'permission denied' error. Permissions and ownership in order.
del \\?\c:\path\to\folder
succeeded. Why does this work when del c:\path\to\folder
does not?
EDIT: Path length was 29 characters, as in:
C:\users\A-AAAAAA\desktop\BBB
(actual format of path with personal info redacted—char counts match. BBB is folder in question).
I think the reason the "full path" works, is because Windows might not be viewing it as a folder when accessed with a fully qualified path.
The del
command is used for deleting files.
The rd
command (remove directory) is used for deleting folders.
If you want to delete a folder run:
rd C:\path\to\folder
If you want to delete a folder tree (including files and subfolders) run:
rd /s C:\path\to\folder
Also, running the command del C:\path\to\folder
in command prompt will actually not delete a folder, but rather delete the contents of that folder, so think of it more like an alias for del C:\path\to\folder\*
.
It was probably a very long pathname or filename? I never heard of this before, but I googled a bit and apparently your syntax can be used to delete those.
Undeletable Files
Files are sometimes created with the very long filenames or reserved names:
CON, AUX, COM1, COM2, COM3, COM4, LPT1, LPT2, LPT3, PRN, NUL
To delete these use the syntax: DEL \\.\C:\somedir\LPT1
Alternatively SUBST a drive letter to the folder containing the file.
User contributions licensed under CC BY-SA 3.0