Scans for empty directories
Inheritance: System.ComponentModel.BackgroundWorker
Example #1
0
        /// <summary>
        /// Start searching empty folders
        /// </summary>
        public void SearchingForEmptyDirectories()
        {
            this.CurrentProcessStep = WorkflowSteps.StartSearchingForEmptyDirs;

            // Rest folder list
            this.Data.ProtectedFolderList = new Dictionary<string, bool>();

            searchEmptyFoldersWorker = new FindEmptyDirectoryWorker();
            searchEmptyFoldersWorker.Data = this.Data;

            searchEmptyFoldersWorker.ProgressChanged += new ProgressChangedEventHandler(searchEmptyFoldersWorker_ProgressChanged);
            searchEmptyFoldersWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(searchEmptyFoldersWorker_RunWorkerCompleted);

            // Start worker
            searchEmptyFoldersWorker.RunWorkerAsync(this.Data.StartFolder);
        }
        /// <summary>
        /// Start searching empty folders
        /// </summary>
        public void SearchingForEmptyDirectories()
        {
            this.CurrentProcessStep = WorkflowSteps.StartSearchingForEmptyDirs;

            // Rest folder list
            this.Data.ProtectedFolderList = new Dictionary <string, bool>();

            searchEmptyFoldersWorker      = new FindEmptyDirectoryWorker();
            searchEmptyFoldersWorker.Data = this.Data;

            searchEmptyFoldersWorker.ProgressChanged    += new ProgressChangedEventHandler(searchEmptyFoldersWorker_ProgressChanged);
            searchEmptyFoldersWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(searchEmptyFoldersWorker_RunWorkerCompleted);

            // Start worker
            searchEmptyFoldersWorker.RunWorkerAsync(this.Data.StartFolder);
        }
        void searchEmptyFoldersWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.CurrentProcessStep = WorkflowSteps.Idle;

            if (e.Error != null)
            {
                this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                this.showErrorMsg(e.Error.Message);
            }
            else if (e.Cancelled)
            {
                if (this.searchEmptyFoldersWorker.ErrorInfo != null)
                {
                    // A error occurred, process was stopped
                    this.showErrorMsg(this.searchEmptyFoldersWorker.ErrorInfo.ErrorMessage);

                    this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                    if (this.OnAborted != null)
                    {
                        this.OnAborted(this, new EventArgs());
                    }
                }
                else
                {
                    this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                    if (this.OnCancelled != null)
                    {
                        this.OnCancelled(this, new EventArgs());
                    }
                }
            }
            else
            {
                int FolderCount = this.searchEmptyFoldersWorker.FolderCount;

                this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                if (this.OnFinishedScanForEmptyDirs != null)
                {
                    this.OnFinishedScanForEmptyDirs(this, new FinishedScanForEmptyDirsEventArgs(this.Data.EmptyFolderList.Count, FolderCount));
                }
            }
        }
Example #4
0
        void searchEmptyFoldersWorker_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            this.CurrentProcessStep = WorkflowSteps.Idle;

            if (e.Error != null)
            {
                this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                this.showErrorMsg(e.Error.Message);
            }
            else if (e.Cancelled)
            {
                if (this.searchEmptyFoldersWorker.ErrorInfo != null)
                {
                    // A error occurred, process was stopped
                    this.showErrorMsg(this.searchEmptyFoldersWorker.ErrorInfo.ErrorMessage);

                    this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                    if (this.OnAborted != null)
                        this.OnAborted(this, new EventArgs());
                }
                else
                {
                    this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                    if (this.OnCancelled != null)
                        this.OnCancelled(this, new EventArgs());
                }
            }
            else
            {
                int FolderCount = this.searchEmptyFoldersWorker.FolderCount;

                this.searchEmptyFoldersWorker.Dispose(); this.searchEmptyFoldersWorker = null;

                if (this.OnFinishedScanForEmptyDirs != null)
                    this.OnFinishedScanForEmptyDirs(this, new FinishedScanForEmptyDirsEventArgs(this.Data.EmptyFolderList.Count, FolderCount));
            }
        }