Directory.EnumerateFiles Exception

I have a very rare behavior.

I am using Windows 10 x64 and Visual Studio 2013 and when I run this code in a 32 bit application

Directory.EnumerateFiles(@"C:\Windows\System32\winevt").Count() 

      

I have an exception of type System.IO.DirectoryNotFoundException

If I open a non admin cmd console and run

dir C:\Windows\System32\winevt

      

the result is a list of folders in the winevt folder. The folder exists and has sub folders.

Any idea?

thank

+3


source to share


1 answer


In the x64 version, all access to System32 is redirected to C: \ Windows \ SystemWOW64.

Try using this option to access it:



 Directory.EnumerateFiles(@"C:\Windows\Sysnative\winevt").Count() 

      

+3


source







All Articles