private List<FileInfo> BuildFileList(DuplicateSearchOption option)
{
NotifyCaller("Start building file list.", OperationStatus.BUILDING_FILE_LIST);
List<FileInfo> fileList = new List<FileInfo>();
Regex re = new Regex(option.FilePattern, option.FileCaseInsensitive ? RegexOptions.IgnoreCase : RegexOptions.None);
int i = 1;
int t = option.Paths.Count;
foreach (var path in option.Paths)
{
try
{
NotifyCaller("Building file list: " + path, OperationStatus.BUILDING_FILE_LIST, curr: i, total: t);
DirectoryInfo dirList = new DirectoryInfo(path);
FileInfo[] tempList = dirList.GetFiles("*", SearchOption.AllDirectories);
// filter based on filepattern
var filteredList = from f in tempList
where re.IsMatch(f.Name)
select f;
fileList.AddRange(filteredList);
++i;
}
catch (Exception ex)
{
NotifyCaller(ex.Message + " (" + path + ")", OperationStatus.ERROR);
}
}
NotifyCaller("Total File: " + fileList.Count, OperationStatus.BUILDING_FILE_LIST, total: fileList.Count);
return fileList;
}