Skip to content

Instantly share code, notes, and snippets.

@kntajus
Created January 31, 2013 13:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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