Halius
1/17/2019 - 4:27 PM

Find and filter files in a directory

Search a directory and get all files depending on a defined array

 //grab all files in directory and filter them by using the extensions               
  string[] extensions = { ".xml", ".raw", ".img", ".bin", ".cor", ".sgf" };
  
  //linq query to get files, change SearchOption accordingly
   var files = Directory.EnumerateFiles(hsFolderPath, "*.*", SearchOption.TopDirectoryOnly)
                    .Where(s => !extensions.Any(ext => ext == Path.GetExtension(s))).ToList();