Missing directory and file info

旧时模样 提交于 2020-01-06 21:09:47

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!