views:

2279

answers:

4

Hi,

I am using this statement to find all files recursively:

fileNames = System.IO.Directory.GetFiles(path, "*.*",
    System.IO.SearchOption.AllDirectories);

The total number of files that are found is sgnificantly lower than wehen using Windows XP Search Companion. This is not caused by hidden files, I checked that. It looks like some directories with a deep nesting level are skipped by GetFiles, but not by Windows Search Companion. GetFiles counts the same number of files as "dir /s" in a command prompt. Anyone have a clue?

Thanks, Neeva

A: 

System files?


What's the result of:

dir/s/as  
dir/s/ah

The search companion could have filters on, have you checked that?

And can you publish the search result?

chakrit
+1  A: 

Can you confirm that there is no exception thrown?

Particularly, PathTooLongException?

try {
    fileNames = System.IO.Directory.GetFiles(path, "*.*",
        System.IO.SearchOption.AllDirectories);

} catch (System.IOPathTooLongException) {
    System.Diagnostics.Debug.Fail("Some path is too long to be processed.");

}
chakrit
+5  A: 

Search Companion looks inside ZIP files. Do you have any of those in the directory tree?

James Curran
A: 

Yes, I have checked search filters. In theory, because filter for hidden files was off, it could have returned more results. I checked that it didn't, there are no hidden files.

I also checked that no exceptions are thrown.

Dir /as returned no results, neither did dir /ah. That leaves ZIP files as a possibility. I noticed that Windows Search Companion displays some result in a short format, without "c:\" in the pathname. When I open the containing folder I now notice that it is indeed inside a ZIP file!! I did not spot the ZIP file icon in the path tree in Windows Explorer before.

Thanks a lot James and Chakrit for your suggestions!

Regards, Neeva

Don't forget to accept the best comment
MSalters