Hi... Use below Query to get your desired files type collection:
  1. string FolderPath = @"D:\AllFiles";
  2. DirectoryInfo di = new DirectoryInfo(FolderPath)
  3. //Get All csv Files
  4. List getAllCSVFiles = di.GetFiles("*.csv")
  5. .Where(file => file.Name.EndsWith(".csv"))
  6. .Select(file => file.Name).ToList();
  7. //Get All Notepad Files
  8. List getAllNotePadFiles = di.GetFiles("*.txt")
  9. .Where(file => file.Name.EndsWith(".txt"))
  10. .Select(file => file.Name).ToList();
Just pass your file extension and enjoy