问题
The following is not returning a full list of files and directories:
IEnumerable<FileSystemInfo> files = new DirectoryInfo("C:\\Windows\\System32\\drivers").EnumerateFileSystemInfos("*", SearchOption.AllDirectories);
The application is run as a administrator. There are no additional file filter drivers in place.
For example if I run:
foreach (FileSystemInfo file in files)
{
Console.WriteLine(file.Name);
}
I get:
en-US
gm.dls
gmreadme.txt
UMDF
wimmount.sys
bfe.dll.mui
ndiscap.sys.mui
pacer.sys.mui
qwavedrv.sys.mui
scfilter.sys.mui
tcpip.sys.mui
I'm at a loss why it wouldn't be outputting all the directories and files.
回答1:
On 64-bit machines, some portions of the file system (and registry) are virtualized. It appears to me that you're running on a 64-bit machine and you are targeting x86 (or AnyCPU with the "Prefer 32-bit" setting) in your build. In 32-bit processes on 64-bit machines, C:\Windows\System32
is redirected to C:\Windows\SysWOW64
. If you look at your C:\Windows\SysWOW64\drivers
folder, you'll see exactly the files you are seeing in your output.
来源:https://stackoverflow.com/questions/30310805/missing-directory-and-file-info