Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 879
animaonline Avatar asked May 06 '26 22:05

animaonline


1 Answers

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.

like image 170
David Heffernan Avatar answered May 08 '26 12:05

David Heffernan