public List <CompareResult> LeftCompare(string leftFolder, string rightFolder) { List <CompareResult> _leftResults = new List <CompareResult>(); List <string> leftFiles = DirectoryLister.GetAllFiles(leftFolder); List <string> rightFiles = DirectoryLister.GetAllFiles(rightFolder); _reference.ReportProgress(15); foreach (string fileOrFolder in leftFiles) { if (fileOrFolder.IsFile()) { _leftResults.Add(ProcessFile(fileOrFolder, rightFiles, CompareDirection.Left)); } else if (DirectoryComparerBaseInfo.Recursive) { _leftResults.AddRange(ProcessFolder(fileOrFolder, rightFiles, CompareDirection.Left)); } } _reference.ReportProgress(50); return(_leftResults); }
private List <CompareResult> Compare(string firstFolder, string secondFolder) { var results = new List <CompareResult>(); var leftFiles = DirectoryLister.GetAllFiles(firstFolder); var rightFiles = DirectoryLister.GetAllFiles(secondFolder); _reference.AddStepProgress(); foreach (string fileOrFolder in leftFiles) { if (fileOrFolder.IsFile()) { results.Add(ProcessFile(fileOrFolder, rightFiles, CompareDirection.Left)); } else if (DirectoryComparerBaseInfo.Recursive) { results.AddRange(ProcessFolder(fileOrFolder, rightFiles, CompareDirection.Left)); } } _reference.AddStepProgress(); return(results); }
public List <CompareResult> RightCompare(string rightFolder, string leftFolder) { List <CompareResult> _rightResults = new List <CompareResult>(); List <string> leftFiles = DirectoryLister.GetAllFiles(leftFolder); List <string> rightFiles = DirectoryLister.GetAllFiles(rightFolder); _reference.ReportProgress(70); foreach (string fileOrFolder in rightFiles) { if (fileOrFolder.IsFile()) { CompareResult result = ProcessFile(fileOrFolder, leftFiles, CompareDirection.Right); if (IsNotPresent(result)) { _rightResults.Add(result); } } else if (DirectoryComparerBaseInfo.Recursive) { List <CompareResult> results = ProcessFolder(fileOrFolder, leftFiles, CompareDirection.Right); _rightResults.AddRange(GetRightOnly(results)); } } _reference.ReportProgress(90); return(_rightResults); }
private List <CompareResult> ProcessFolder(string fileOrFolder, List <string> otherFiles, CompareDirection direction) { List <CompareResult> results = new List <CompareResult>(); string dirName = '\\' + fileOrFolder.GetCurrentDir(); string correspondingDir = otherFiles.SingleOrDefault(r => r.IsDirectory() && r.EndsWith(dirName)); if (correspondingDir != null) { List <string> leftFiles = DirectoryLister.GetAllFiles(fileOrFolder); List <string> cRightFiles = DirectoryLister.GetAllFiles(correspondingDir); if (leftFiles.Count == 0 && cRightFiles.Count == 0) { results.Add(ProcessEmptyDirectory(fileOrFolder, correspondingDir, direction)); } else { foreach (string fileorFolder in leftFiles) { results.AddRange(ProcessByType(fileorFolder, cRightFiles, direction)); } } } else { List <string> files = DirectoryLister.GetAllFiles(fileOrFolder); if (files.Count > 0) { foreach (var file in files) { results.AddRange(ProcessByType(file, null, direction)); } } else { results.Add(ProcessEmptyDirectory(fileOrFolder, string.Empty, direction)); } } return(results); }