Exemplo n.º 1
0
        private void tree_OnDeleteRequest(object sender, DeleteRequestFromTreeEventArgs e)
        {
            try
            {
                var deletePath = e.Directory;

                // To simplify the code here there is only the RecycleBinWithQuestion or simulate possible here
                // (all others will be ignored)
                SystemFunctions.ManuallyDeleteDirectory(deletePath, (DeleteModes)Properties.Settings.Default.delete_mode);

                // Remove root node
                this.tree.RemoveNode(deletePath);

                this.Data.AddLogMessage("Manually deleted: \"" + deletePath + "\" including all subdirectories");

                // Disable the delete button because the user has to re-scan after he manually deleted a directory
                this.btnDelete.Enabled = false;
            }
            catch (System.OperationCanceledException)
            {
                // The user canceled the deletion
            }
            catch (Exception ex)
            {
                this.Data.AddLogMessage("Could not manually delete \"" + e.Directory + "\" because of the following error: " + ex.Message);

                MessageBox.Show(this, "The directory was not deleted, because of the following error:" + Environment.NewLine + ex.Message);
            }
        }
        private void tree_OnDeleteRequest(object sender, DeleteRequestFromTreeEventArgs e)
        {
            try
            {
                var deletePath = e.Directory;

                // To simplify the code here there is only the RecycleBinWithQuestion or simulate possible here
                // (all others will be ignored)
                SystemFunctions.ManuallyDeleteDirectory(deletePath, (DeleteModes)Properties.Settings.Default.delete_mode);

                // Remove root node
                this.tree.RemoveNode(deletePath);

                this.Data.AddLogMessage("Manually deleted: \"" + deletePath + "\" including all subdirectories");

                // Disable the delete button because the user has to re-scan after he manually deleted a directory
                this.btnDelete.Enabled = false;

            }
            catch (System.OperationCanceledException)
            {
                // The user canceled the deletion
            }
            catch (Exception ex)
            {
                this.Data.AddLogMessage("Could not manually delete \"" + e.Directory + "\" because of the following error: " + ex.Message);

                MessageBox.Show(this, "The directory was not deleted, because of the following error:" + Environment.NewLine + ex.Message);
            }
        }