I tried to write a method to enumerate all directories recursively, and then compared its result with dir command result. It appears that some directories are returned by dir and ignored by GetDirectories, for example:
Directory.GetDirectories(@"C:\Windows\System32\spp")
returns an array with a single element - "C:\\Windows\\System32\\spp\\tokens"
and
dir "C:\Windows\System32\spp" /b /a:d
returns three directories:
plugin-manifests-signed
store
tokens
Another example is the C:\Windows\System32\spool directory, it is not listed in Directory.GetDirectories(@"C:\Windows\System32")
but appears in dir "C:\Windows\System32" /b /a:d
, as well as some other directories under C:\Windows\System32
Vice versa, there are directories not visible in explorer and not listed in dir output, although returned by GetDirectories, in my case it was C:\Windows\System32\InstallShield and its subdirectories.
Not that I want to manipulate those directories, but it made me curious, what is so special about C:\Windows\System32\InstallShield, C:\Windows\System32\spp subdiresctories and others that they are visible in one way and not in another.
I'm using C# 6.0 and Windows 10 version 1803