Restrict a list of files to valid extensions only
using System.IO; using System.Collections.Generic; using System.Windows.Forms; using System.Text.RegularExpressions; public class Utils { public static List<string> GetValidFiles(List<string> FileList, string sValidExt) { return FileList.FindAll(sFileName => sValidExt.Contains(new FileInfo(sFileName).Extension.ToLower())); } }