private void FindPhotosInDirectory(string directoryPath) { var subDirectories = Directory.GetDirectories(directoryPath); // Recursively process each directory foreach (var subDirectory in subDirectories) { // TODO: Add support for configurable ignore files/dirs if (Path.GetFileName(subDirectory).Equals("@eaDir", StringComparison.InvariantCultureIgnoreCase)) { continue; } FindPhotosInDirectory(subDirectory); } // Get each file path in directory var pathsOfDirectoryFiles = new List <string>(); foreach (var filePath in Directory.GetFiles(directoryPath)) { pathsOfDirectoryFiles.Add(filePath); } // Filter to only include photos (and videos) // TODO: Replace magical strings with crawler recognized extensions settings var photoRegex = new Regex(@".*\.(gif|jpe?g|bmp|png|vmv)$", RegexOptions.IgnoreCase); var videoRegex = new Regex(@".*\.(mov|mpe?g|mp4|avi)$", RegexOptions.IgnoreCase); var pathsOfDirectoryPhotos = pathsOfDirectoryFiles .Where(p => photoRegex.IsMatch(p) || videoRegex.IsMatch(p)) .ToList(); // Process each photo in directory for (var index = 0; index < pathsOfDirectoryPhotos.Count; index++) { var filePath = pathsOfDirectoryPhotos[index]; var(photo, error) = PhotoReader.ReadPhoto(filePath, false, true); if (photo != null) { _list.Add(photo); } if (error != null) { _errorList.Add(error); } var progressReport = new ProgressReport( $"Find photos {directoryPath}", index, pathsOfDirectoryPhotos.Count); _outputPort?.HandleProgress(progressReport); } }