animaonline
animaonline

Reputation: 3804

Directory.GetFiles Not returning a file

I have manually created a text file called AAAAA.txt in c:\windows\System32 , when I execute the following code:

var sys32Files = Directory.GetFiles(@"C:\windows\System32");

It returns a bunch of files, but AAAAA.txt is not in that list. All permissions on the AAAAA.txt are the same as on those file that get returned.

Could someone explain what may be the issue here?

And yes, I'm running as an administrator.

Upvotes: 2

Views: 1656

Answers (1)

David Heffernan
David Heffernan

Reputation: 612964

You have a 64 bit machine and are running a 32 bit process. The file system redirector means that C:\Windows\system32 is redirected to C:\Windows\SysWOW64. If you want to find files in C:\Windows\system32 you can use the C:\Windows\sysnative alias. Or compile for 64 bit.

Of course you should not be creating files in the system directory in the first place. It belongs to Windows and you should leave it well alone.

Upvotes: 9

Related Questions