I've somehow ended up with an empty directory (created some months ago with NodeJS as part of a script I ran) that can't be deleted with a regular rmdir. I can copy-paste the directory as many times as I like and even the copies will remain undeletable with rmdir:
C:\testing>dir
Volume in drive C is Local Disk
Volume Serial Number is 8830-C25A
Directory of C:\testing
20/07/2020 04:47 PM <DIR> .
20/07/2020 04:47 PM <DIR> ..
20/07/2020 01:25 PM <DIR> test
0 File(s) 0 bytes
3 Dir(s) 43,126,059,008 bytes free
C:\testing>rmdir test
Access is denied.
That's on an administrator cmd prompt, and I even set all the permissions on the directory to Full control:
By all indications, the directory is totally empty; I turned on hidden and system files in Explorer and I see no subdirectories or files, and a dir /a shows nothing either:
C:\testing\test>dir /a
Volume in drive C is Local Disk
Volume Serial Number is 8830-C25A
Directory of C:\testing\test
20/07/2020 01:25 PM <DIR> .
20/07/2020 01:25 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 43,123,294,208 bytes free
Doing attrib in the dir shows nothing:
C:\testing\test>attrib
File not found - C:\testing\test\*.*
The other odd thing is that it's telling me Access is denied when I try to rmdir rather than The directory is not empty.
I also considered that some program may have an open handle for the directory (as unlikely as that is after copy-pasting from the original). Well, after checking with everything I could think of (LockHunter, Process Explorer handle search, Resource Monitor handle search and Sysinternals' Handle program) I could see no open handles anywhere.
So at this point, it seems like something's up, right? Well what's really strange is that if I do rmdir /s test (recursive delete) it deletes just fine:
C:\testing>rmdir /s test
test, Are you sure (Y/N)? y
C:\testing>dir
Volume in drive C is Local Disk
Volume Serial Number is 8830-C25A
Directory of C:\testing
20/07/2020 04:58 PM <DIR> .
20/07/2020 04:58 PM <DIR> ..
0 File(s) 0 bytes
2 Dir(s) 43,120,893,952 bytes free
This implies that there's actually something inside test. What could it be? I'm really curious, because nothing I've done so far has shown me anything useful. I simply can't figure out what's causing rmdir test to fail on this particular directory (or any copies of it).
So my official question: What's causing this bizarre behaviour?

