private void LookForSequenceInIndexedDirectory(MainViewModel vm, string path, string sequence, ICollection <SearchCondition> conditions = null) { using (var reader = new IndexFileReader(IndexPaths.GetIdxFilePath(path))) { IEnumerable <IndexedItem> items = reader.ReadAll(); //Parallel.ForEach(items, (item) => //{ foreach (var item in items) { var size = (double)item.Length / 1024 / 1024; if (CheckSearchConditions(item, conditions) && CheckDateRange(item, vm.SearchDatesRange) && CheckSizeRange(item, vm.SizeRange)) { if (sequence.Equals("*") || item.Name.ToLower().Contains(sequence.ToLower())) { vm.SearchResults.Add(item); vm.TotalFilesMatch++; _cancellationToken.ThrowIfCancellationRequested(); } vm.TotalFilesSize += size; vm.TotalFilesCount++; vm.CurrentProgressBarValue++; } } //}); } }
private long GetIndexedDirectoryFilesCount(string path) { using (var reader = new IndexFileReader(IndexPaths.GetIdxFilePath(path))) { return(reader.ReadAll().Count()); } }
private void Index(string path, ProgressDialog dialog) { IList <IndexedItem> items = GetFilesToIndex(new DirectoryInfo(path), dialog); if (dialog.CancellationPending) { File.Delete(IndexPaths.GetIdxFilePath(path)); return; } using (var writer = new IndexFileWriter(IndexPaths.GetIdxFilePath(path))) { writer.Write(items); } }