As far as I can see, you can only specify one pattern at a time (unless there's something new in 2.0 that I've missed) so I thought this was a good candidate for a simple wrapper. The code below should be fairly easy to modify if you have any specific requirements in your situation.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
namespace Diuturnal.Utility { | |
public class DirectoryHelper { | |
public static FileInfo[] GetFiles(DirectoryInfo directory, | |
params string[] searchPatterns) { | |
List<FileInfo> allFiles = new List<FileInfo>(); | |
foreach (string pattern in searchPatterns) { | |
allFiles.AddRange(directory.GetFiles(pattern)); | |
} | |
allFiles.Sort(delegate(FileInfo x, FileInfo y) | |
{ return x.Name.CompareTo(y.Name); }); | |
return allFiles.ToArray(); | |
} | |
} | |
} |
No comments:
Post a Comment