我有一个非常罕见的行为。
我正在使用 Windows 10 x64 和 Visual Studio 2013,当我在 32 位应用程序中运行此代码时
Directory.EnumerateFiles(@"C:\Windows\System32\winevt").Count()
我有一个 System.IO.DirectoryNotFoundException 类型的异常
如果我打开一个非管理员 cmd 控制台并运行
dir C:\Windows\System32\winevt
结果是 winevt 文件夹中的文件夹列表。该文件夹存在并具有子文件夹。
有什么想法吗?
谢谢
最佳答案
在 x64 版本中 - 所有对 System32 的访问都重定向到 C:\Windows\SystemWOW64。
尝试使用这个变体来访问它:
Directory.EnumerateFiles(@"C:\Windows\Sysnative\winevt").Count()
关于c# - Directory.EnumerateFiles 异常,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31832758/