public DuplicateViewModel() { Bc = new BitMapCreator(); if (DesignerProperties.GetIsInDesignMode(new DependencyObject())) { var dff = new DuplicateFileFinder( null, new Directory(@"C:\Users\Kevin\OneDrive\duptest")); dff.FindDuplicates(); FileMapByString fm = dff._duplicates; foreach (var item in fm) { foreach (IFile file in item.Value) { dff_OnDuplicateFound(item.Key, file.Path, file.GetSize()); } } } }
private async Task BuildDuplicatesList(FileMapBySize fileMapBySize) { var fileMapByHashCode = new FileMapByString(); foreach (IFile file in fileMapBySize.GetPotentialDuplicates()) { try { string hash = await file.GetUniqueHash(dispatcher, OnHashProgress); List <IFile> list; if (!fileMapByHashCode.TryGetValue(hash, out list)) { list = new List <IFile>(); fileMapByHashCode.Add(hash, list); } list.Add(file); // Once we have two files with the same hashcode // we know that a duplicate has been found if (list.Count > 1) { if (!_duplicates.ContainsKey(hash)) { _duplicates.Add(hash, list); } NotifyDuplicateFound(list, hash, file); } } catch (Exception e) { NotifyFileReadError(file, e); } } }
private async Task BuildDuplicatesList(FileMapBySize fileMapBySize) { var fileMapByHashCode = new FileMapByString(); foreach (IFile file in fileMapBySize.GetPotentialDuplicates()) { try { string hash = await file.GetUniqueHash(dispatcher, OnHashProgress); List<IFile> list; if (!fileMapByHashCode.TryGetValue(hash, out list)) { list = new List<IFile>(); fileMapByHashCode.Add(hash, list); } list.Add(file); // Once we have two files with the same hashcode // we know that a duplicate has been found if (list.Count > 1) { if (!_duplicates.ContainsKey(hash)) { _duplicates.Add(hash, list); } NotifyDuplicateFound(list, hash, file); } } catch (Exception e) { NotifyFileReadError(file, e); } } }