Esempio n. 1
0
 public void InitialDirectoryWalk()
 {
     CloneFinderCore.DirectoryWalker testDirectoryWalk = new CloneFinderCore.DirectoryWalker(@"C:\Users\sherman");
     testDirectoryWalk.DirectoryWalkStarted += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(DirectoryWalk_DirectoryWalkStarted);
     testDirectoryWalk.DirectoryWalkComplete += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(DirectoryWalk_DirectoryWalkComplete);
     testDirectoryWalk.WalkDirectory();
 }
Esempio n. 2
0
 public void InitialDirectoryWalk()
 {
     CloneFinderCore.DirectoryWalker testDirectoryWalk = new CloneFinderCore.DirectoryWalker(@"C:\Users\sherman");
     testDirectoryWalk.DirectoryWalkStarted  += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(DirectoryWalk_DirectoryWalkStarted);
     testDirectoryWalk.DirectoryWalkComplete += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(DirectoryWalk_DirectoryWalkComplete);
     testDirectoryWalk.WalkDirectory();
 }
Esempio n. 3
0
 void backgroundWorkerSearch_DoWork(object sender, DoWorkEventArgs e)
 {
     CloneFinderCore.DirectoryWalker directoryWalk = new CloneFinderCore.DirectoryWalker(this.textBoxSearchPath.Text);
     directoryWalk.FileProcessed += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_FileProcessed);
     directoryWalk.FileAccessed += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_FileAccessed);
     directoryWalk.DirectoryWalkComplete += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_DirectoryWalkComplete);
     Collection<CloneFinderCore.ProcessedFileInfo> duplicates = directoryWalk.WalkDirectory();
     e.Result = duplicates;
 }
Esempio n. 4
0
        void backgroundWorkerSearch_DoWork(object sender, DoWorkEventArgs e)
        {
            CloneFinderCore.DirectoryWalker directoryWalk = new CloneFinderCore.DirectoryWalker(this.textBoxSearchPath.Text);
            directoryWalk.FileProcessed         += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_FileProcessed);
            directoryWalk.FileAccessed          += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_FileAccessed);
            directoryWalk.DirectoryWalkComplete += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(directoryWalk_DirectoryWalkComplete);
            Collection <CloneFinderCore.ProcessedFileInfo> duplicates = directoryWalk.WalkDirectory();

            e.Result = duplicates;
        }
Esempio n. 5
0
 public void FindDuplicates(Options commandLineOptions)
 {
     CloneFinderCore.DirectoryWalker duplicateWalker = new CloneFinderCore.DirectoryWalker(commandLineOptions.Items[0]);
     if (commandLineOptions.progressIndicator)
     {
         duplicateWalker.FileProcessed += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(duplicateWalker_FileProcessed);
         duplicateWalker.DirectoryWalkComplete += new EventHandler<CloneFinderCore.DirectoryWalkEventArgs>(duplicateWalker_DirectoryWalkComplete);
     }
     Collection<CloneFinderCore.ProcessedFileInfo> duplicateFiles = duplicateWalker.WalkDirectory();
     WriteResults(duplicateFiles, commandLineOptions.csvOutput);
 }
Esempio n. 6
0
        public void FindDuplicates(Options commandLineOptions)
        {
            CloneFinderCore.DirectoryWalker duplicateWalker = new CloneFinderCore.DirectoryWalker(commandLineOptions.Items[0]);
            if (commandLineOptions.progressIndicator)
            {
                duplicateWalker.FileProcessed         += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(duplicateWalker_FileProcessed);
                duplicateWalker.DirectoryWalkComplete += new EventHandler <CloneFinderCore.DirectoryWalkEventArgs>(duplicateWalker_DirectoryWalkComplete);
            }
            Collection <CloneFinderCore.ProcessedFileInfo> duplicateFiles = duplicateWalker.WalkDirectory();

            WriteResults(duplicateFiles, commandLineOptions.csvOutput);
        }
Esempio n. 7
0
        public void DirectoryWalker_DoesConstructorRejectNullArgument()
        {
            // Constructor should throw exception
            // when a null, empty, whitespace is the parameter
            bool nullParameterTest = false;

            try
            {
                CloneFinderCore.DirectoryWalker nullParameter = new CloneFinderCore.DirectoryWalker(null);
            }
            catch (ArgumentNullException)
            {
                nullParameterTest = true;
            }
            Assert.IsTrue(nullParameterTest, "ArgumentNullException caught when constructor is passed null.");

            bool emptyStringParameterTest = false;

            try
            {
                CloneFinderCore.DirectoryWalker emptyStringParameter = new CloneFinderCore.DirectoryWalker(String.Empty);
            }
            catch (ArgumentNullException)
            {
                emptyStringParameterTest = true;
            }
            Assert.IsTrue(emptyStringParameterTest);

            bool whiteSpaceParameterTest = false;

            try
            {
                CloneFinderCore.DirectoryWalker whiteSpaceParameter = new CloneFinderCore.DirectoryWalker("    ");
            }
            catch (ArgumentNullException)
            {
                whiteSpaceParameterTest = true;
            }
            Assert.IsTrue(whiteSpaceParameterTest);
        }
Esempio n. 8
0
 private void Search()
 {
     // Make sure we're searching on a valid folder
     if (Directory.Exists(this.textBoxSearchPath.Text))
     {
         this.Cursor = Cursors.WaitCursor;
         try
         {
             this.labelStatus.Text = String.Empty;
             this.dataGridViewResults.DataSource = null;
             CloneFinderCore.DirectoryWalker directoryWalk             = new CloneFinderCore.DirectoryWalker(this.textBoxSearchPath.Text);
             Collection <CloneFinderCore.ProcessedFileInfo> duplicates = directoryWalk.WalkDirectory();
             if (duplicates != null && duplicates.Count > 0)
             {
                 this.dataGridViewResults.DataSource = duplicates;
                 this.labelStatus.Text = duplicates.Count.ToString() + " duplicate files found.";
             }
             else
             {
                 MessageBox.Show("No duplicates were found in this folder.", "No duplicates", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.labelStatus.Text = "No duplicate files found.";
             }
         }
         finally
         {
             this.Cursor = Cursors.Default;
         }
     }
     else
     {
         MessageBox.Show("A valid folder to search has not been entered/selected.", "Invalid folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         if (!String.IsNullOrEmpty(this.folderBrowserDialogSearch.SelectedPath) && Directory.Exists(this.folderBrowserDialogSearch.SelectedPath))
         {
             this.textBoxSearchPath.Text = this.folderBrowserDialogSearch.SelectedPath;
         }
         this.textBoxSearchPath.Focus();
     }
 }
Esempio n. 9
0
        public void DirectoryWalker_DoesConstructorRejectNullArgument()
        {
            // Constructor should throw exception
            // when a null, empty, whitespace is the parameter
            bool nullParameterTest = false;
            try
            {
                CloneFinderCore.DirectoryWalker nullParameter = new CloneFinderCore.DirectoryWalker(null);
            }
            catch (ArgumentNullException)
            {
                nullParameterTest = true;
            }
            Assert.IsTrue(nullParameterTest, "ArgumentNullException caught when constructor is passed null.");

            bool emptyStringParameterTest = false;
            try
            {
                CloneFinderCore.DirectoryWalker emptyStringParameter = new CloneFinderCore.DirectoryWalker(String.Empty);
            }
            catch (ArgumentNullException)
            {
                emptyStringParameterTest = true;
            }
            Assert.IsTrue(emptyStringParameterTest);

            bool whiteSpaceParameterTest = false;
            try
            {
                CloneFinderCore.DirectoryWalker whiteSpaceParameter = new CloneFinderCore.DirectoryWalker("    ");
            }
            catch (ArgumentNullException)
            {
                whiteSpaceParameterTest = true;
            }
            Assert.IsTrue(whiteSpaceParameterTest);
        }
Esempio n. 10
0
 private void Search()
 {
     // Make sure we're searching on a valid folder
     if (Directory.Exists(this.textBoxSearchPath.Text))
     {
         this.Cursor = Cursors.WaitCursor;
         try
         {
             this.labelStatus.Text = String.Empty;
             this.dataGridViewResults.DataSource = null;
             CloneFinderCore.DirectoryWalker directoryWalk = new CloneFinderCore.DirectoryWalker(this.textBoxSearchPath.Text);
             Collection<CloneFinderCore.ProcessedFileInfo> duplicates = directoryWalk.WalkDirectory();
             if (duplicates != null && duplicates.Count > 0)
             {
                 this.dataGridViewResults.DataSource = duplicates;
                 this.labelStatus.Text = duplicates.Count.ToString() + " duplicate files found.";
             }
             else
             {
                 MessageBox.Show("No duplicates were found in this folder.", "No duplicates", MessageBoxButtons.OK, MessageBoxIcon.Information);
                 this.labelStatus.Text = "No duplicate files found.";
             }
         }
         finally
         {
             this.Cursor = Cursors.Default;
         }
     }
     else
     {
         MessageBox.Show("A valid folder to search has not been entered/selected.", "Invalid folder", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
         if (!String.IsNullOrEmpty(this.folderBrowserDialogSearch.SelectedPath) && Directory.Exists(this.folderBrowserDialogSearch.SelectedPath))
         {
             this.textBoxSearchPath.Text = this.folderBrowserDialogSearch.SelectedPath;
         }
         this.textBoxSearchPath.Focus();
     }
 }