简体   繁体   中英

DirectoryInfo.GetFiles() Not returning all files

I am just experimenting a little with my own folder browser. I notice that when I look at the System32 folder in Windows 7 I am getting some strange results. Here's the code:

DataTable dt=new DataTable();
string Folder="C:\\Windows\\System32";
DirectoryInfo DI = new DirectoryInfo(Folder);
foreach (FileInfo FI in DI.GetFiles())
{
    DataRow Row = dt.NewRow();
    if(FI.Name== "accelerometerdll.DLL")
    {

    }
    Row["Name"] = FI.Name;
    Row["Created"] = FI.CreationTime;

    Row["Size"] = FI.Length;
    dt.Rows.Add(Row);
}
dataGridView1.DataSource = dt;

When run, the list of files is incomplete. The total number of files is off by more than 400 files compared to windows explorer.

There is a simple check for the file named "accelerometerdll.dll" to try to resolve this issue. That file is, absolutely, located in the System32 folder. I can see it in Explorer and I can see it in the command window when I do a DIR . Yet it never shows up in my datatable. The condition is never met. Its like its simply invisible. I've tried running this as administrator with the same results.

Even more disconcerting is that it does show a file called "12520437.cpx" and I cannot see it in either explorer or the command window. It appears to be in the SysWOW64 folder not the System32 folder???

My main goal here is to show EXACTLY the same files that explorer shows when I open any folder.

Any ideas?

It was necessary to turn off the prefer 32 bit compiler directive based on knowledgeable responses.

More info is available here:

File System Redirector

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM