none
Strange Directory.GetFiles() issue RRS feed

  • Question

  • Hi, 

    I am having a really bizarre issue.  This is my code in Linqpad [This issue is not specific to Linqpad]:

    void Main()
    {
    string sourceDir =@"\\Server\States\WV";

    List<string> files = Directory.GetFiles(sourceDir, "*WV43*", SearchOption.AllDirectories).ToList();

    files.Dump();
    }

    I see the following results:

    \\Server\States\WV\WV1000600.PDF 
    \\\Server\States\WV\WV11239MISC.PDF 

    Not sure why these files are showing up when they don't have WV43 string in their names.

    What am I missing here?

    Thanks,

    Manu

    Thursday, June 20, 2013 1:12 PM

Answers

  • Wildcard searches use both the long and short file names.  As such you can get back matches against the short name that don't line up with the long name.  It is documented here.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    • Marked as answer by mnu_m Thursday, June 20, 2013 5:46 PM
    Thursday, June 20, 2013 4:47 PM
    Moderator

All replies

  • Wildcard searches use both the long and short file names.  As such you can get back matches against the short name that don't line up with the long name.  It is documented here.

    Michael Taylor
    http://msmvps.com/blogs/p3net

    • Marked as answer by mnu_m Thursday, June 20, 2013 5:46 PM
    Thursday, June 20, 2013 4:47 PM
    Moderator
  • Thanks Michael.
    Thursday, June 20, 2013 5:46 PM