/// <summary> /// Copy function. Attention! /// </summary> private void CompareDirectoryThread() { // Get the overal amount of data //DirectoryInfo dir = new DirectoryInfo(sourceDir); // Start the elapsed time measurements Stopwatch _stopwatch = new Stopwatch(); _stopwatch.Start(); // get the size of the source directory //GetDirectoryMegaByteSize(this.sourceDir, true); // Preset the Finished Arguments finishedEventArgs.allFilesComparedAndNoDifferences = true; finishedEventArgs.differentFiles = new List <string>(); finishedEventArgs.foundDirectorysThatShouldNotExist = new List <string>(); finishedEventArgs.foundFilesThatShouldNotExist = new List <string>(); finishedEventArgs.notFoundDirectorys = new List <string>(); finishedEventArgs.notFoundFiles = new List <string>(); // Perform the Copy CompareDirectory(this.sourceDir, this.destinationDir, true); // get the size of the destination directory //GetDirectoryMegaByteSize(this.destinationDir, true); // After we are done send teh finished Event _stopwatch.Stop(); finishedEventArgs.timeElapsed = _stopwatch.ElapsedMilliseconds; // Hit the event that we have finished without copying anything CompareFinished.Invoke(this, finishedEventArgs); }
/// <summary> /// Synchronous call of the Working method /// </summary> /// <param name="sourceDirectory"></param> /// <param name="destinationDirectory"></param> public void CompareDirectorySynch(string sourceDirectory, string destinationDirectory) { finishedEventArgs.sourceDir = sourceDirectory; finishedEventArgs.destinationDir = destinationDirectory; // Set the directorys this.destinationDir = destinationDirectory; this.sourceDir = sourceDirectory; // Check if Data is valid if (Directory.Exists(sourceDir)) { // Start the Copying thread CompareDirectoryThread(); } else { finishedEventArgs.allFilesComparedAndNoDifferences = false; finishedEventArgs.notFoundDirectorys = new List <string>(); finishedEventArgs.notFoundDirectorys.Add(sourceDir); finishedEventArgs.timeElapsed = 0; // Hit the event that we have finished without copying anything CompareFinished.Invoke(this, finishedEventArgs); } }