3

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

EGeorge
  • 148
  • 8
  • 1
    Maybe you lack elevation and thus run into Virtualsiation? https://www.codeguru.com/csharp/csharp/cs_misc/designtechniques/article.php/c15455/Tip-To-Disable-Virtualization.htm it is also possible the compiler is going out of it's way to protect your programm directory from bugging applications during development. – Christopher Nov 12 '18 at 13:52

1 Answers1

4

Probably the build your application is set to and its going into the SYSWOW folder instead

You could try replacing that with SYSnative in your path - folder doesnt exist but it seems to work.

I've ran into the same problem trying to enumerate registry keys

Shovers_
  • 497
  • 2
  • 13