Skip to content

Instantly share code, notes, and snippets.

@kntajus
Created January 31, 2013 13:56
Show Gist options
  • Save kntajus/4683031 to your computer and use it in GitHub Desktop.
Save kntajus/4683031 to your computer and use it in GitHub Desktop.
Multiple search patterns with DirectoryInfo.GetFiles()
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();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment