【发布时间】:2015-05-06 11:44:01
【问题描述】:
我正在尝试枚举C:\Windows\system32 和C:\Windows\SysWow64 中的文件。但是我缺少文件csrss.exe 和lsass.exe 可能还有更多,我只检查了这两个文件。
那些文件在那里,我可以在总指挥官和资源管理器中看到它们。它们只是不在枚举结果中。
List<string> result = new List<string>(Directory.EnumerateFiles("C:\\Windows\\system32", "*.exe", SearchOption.TopDirectoryOnly));
我尝试使用DirectoryInfo 而不是Directory,结果相同。
也试过这个:
List<string> result = new List<string>(Directory.EnumerateFileSystemEntries("C:\\Windows\\system32", "*.exe", SearchOption.TopDirectoryOnly));
还有这个:
var dir = new DirectoryInfo("C:\\Windows\\system32");
var result = dir.EnumerateFiles("*.exe", SearchOption.TopDirectoryOnly);
变量“结果”不为空,但不包含提及的文件。
框架版本:v4.0.30319
Windows7:6.1.7601 x64
注意:我知道我可以使用解决方法:dir /a-d /b C:\Windows\system32,然后解析输出。但我想避免这种情况。
【问题讨论】:
-
您的项目是 32 位的吗?如果是这样,您对 system32 文件夹的请求可能会重定向到可能没有这些文件的 syswow64。您可以为 64 位构建或禁用 WOW64 文件夹重定向以查看真实的 system32。
标签: c# windows enumeration system32