Unexpected result in .NET 4 DirectoryInfo.EnumerateFiles(string)

Posted by xkingpin on Stack Overflow See other posts from Stack Overflow or by xkingpin
Published on 2010-05-16T03:19:33Z Indexed on 2010/05/16 3:30 UTC
Read the original article Hit count: 695

Filed under:
|
|

It seems that the following code is not working as expected. I would assume that the following call to EnumarateFiles would only return files that match the filename pattern of c* ... however, filenames with H* are still getting returned. For example... the following file will get deleted in the following code (HNNN09060900932.xml). What's the issue? This is a major bug in my application.

        string searchPattern = "C*";

        // get each file in this directory that is less than a given date
        var files = from file in SubDir.EnumerateFiles(searchPattern)
                    where file.LastWriteTime < KeepDate
                    select file;

        foreach (var file in files)
        {
                file.Delete();
        }

© Stack Overflow or respective owner

Related posts about .NET

Related posts about c#