I know I can use
Directory.GetFiles(sourceDirectory, pattern);
To get ALL the files with a particular pattern. However, I'm curious as to how would one get only the files wanted (i.e. from a list of some sort) with that same pattern?
I know I can use
Directory.GetFiles(sourceDirectory, pattern);
To get ALL the files with a particular pattern. However, I'm curious as to how would one get only the files wanted (i.e. from a list of some sort) with that same pattern?
Dont think you can do straight out of GetFiles, you can surely filter them though....
private static string[] GetFiles(string sourceFolder, string filters, System.IO.SearchOption searchOption, List<string> fileNames )
{
return System.IO.Directory.GetFiles(sourceFolder, filters, searchOption).Where(fileNames.Contains).ToArray();
}
string[] filePaths = filesToReturn.SelectMany(f => Directory.GetFiles(sourceDirectory, f)).ToArray();