/// <summary> /// Crawls the specified parameters. /// </summary> /// <param name="parameters">The parameters.</param> public void Crawl(FileCrawlerParameters parameters) { // Reset cancelled flag: this.ResetCancelled(); // Don't crawl if no observers exist: if (this.observers.Count > 0) { List <FileFolderPath> paths = parameters.PathInfoList; int pathsCount = paths.Count; for (int i = 0; i < pathsCount; i++) { // Check cancelled: if (this.IsCancelled()) { break; } FileFolderPath path = paths[i]; // Notify crawling started: this.NotifyFileCrawlingStarted(path); try { // Check if the specified path is actually a file: if (File.Exists(path.RootPath)) { this.NotifyProcessFile(path, path.RootPath); } else if (Directory.Exists(path.RootPath)) { // Create regex parser if required: Regex regex = null; if (!String.IsNullOrWhiteSpace(path.Pattern)) { regex = new Regex(path.Pattern); } // Get directory info: DirectoryInfo info = new DirectoryInfo(path.RootPath); this.ProcessDirectory(path, info, regex); } } catch (Exception exc) { // Notify error: this.NotifyErrorOccurred(path, exc); } finally { // Notify path crawling finished: this.NotifyFileCrawlingFinished(path); } } } }
/// <summary> /// Crawls the specified parameters. /// </summary> /// <param name="parameters">The parameters.</param> public void Crawl(FileCrawlerParameters parameters) { // Reset cancelled flag: this.ResetCancelled(); // Don't crawl if no observers exist: if (this.observers.Count > 0) { List<FileFolderPath> paths = parameters.PathInfoList; int pathsCount = paths.Count; for (int i = 0; i < pathsCount; i++) { // Check cancelled: if (this.IsCancelled()) break; FileFolderPath path = paths[i]; // Notify crawling started: this.NotifyFileCrawlingStarted(path); try { // Check if the specified path is actually a file: if (File.Exists(path.RootPath)) { this.NotifyProcessFile(path, path.RootPath); } else if (Directory.Exists(path.RootPath)) { // Create regex parser if required: Regex regex = null; if (!String.IsNullOrWhiteSpace(path.Pattern)) regex = new Regex(path.Pattern); // Get directory info: DirectoryInfo info = new DirectoryInfo(path.RootPath); this.ProcessDirectory(path, info, regex); } } catch (Exception exc) { // Notify error: this.NotifyErrorOccurred(path, exc); } finally { // Notify path crawling finished: this.NotifyFileCrawlingFinished(path); } } } }