Wednesday, March 23, 2011

System.IO.Directory.GetFiles returns different result than Windows XP Search Companion

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

From stackoverflow
  • 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?

  • 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.");
    
    }
    
  • Search Companion looks inside ZIP files. Do you have any of those in the directory tree?

  • 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

    MSalters : Don't forget to accept the best comment

0 comments:

Post a Comment