Directory.EnumerateFilesexception

我有一个非常罕见的行为。

我正在使用Windows 10 x64和Visual Studio 2013,当我在32位应用程序中运行此代码

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

我有一个System.IO.DirectoryNotFoundExceptiontypes的exception

如果我打开一个非pipe理员cmd控制台,我运行

 dir C:\Windows\System32\winevt 

结果是winevt文件夹中的文件夹列表。 该文件夹存在并具有子文件夹。

任何想法?

谢谢

在x64版本中 – 对System32的所有访问都重定向到C:\ Windows \ SystemWOW64。

尝试使用这个变体来访问它:

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