Deleting file by specifying full path - why does this work?

1

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).

windows-7
unc
asked on Super User Feb 12, 2015 by meatspace • edited Feb 12, 2015 by meatspace

2 Answers

2

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\*.

answered on Super User Feb 12, 2015 by Kristian
1

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.

http://ss64.com/nt/del.html:

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.
answered on Super User Feb 12, 2015 by SadBunny

User contributions licensed under CC BY-SA 3.0