示例#1
0
        private void btnSpFunFindNotInTargetPathFileByFileName_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction(txtConsole);
                sporadicFunction.SetFileSelectParm(this.GetFormFileSelParm());

                string fileNames = sporadicFunction.Execute_FindNotInTargetPathFileByFileName();

                if (fileNames.Length > 0)
                {
                    using (formTextMessage frmMessage = new formTextMessage("找到的文件列表", fileNames, true))
                    {
                        frmMessage.ShowDialog(this);
                    }
                }
                else
                {
                    CommFunction.WriteMessage("没有找到此类文件。");
                }

                UIInProcess(false);
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
示例#2
0
        private void btnSpFunDeleteEmptyFolder_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction();
                FileSelectParm       fileSelParm      = this.GetFormFileSelParm();
                if (fileSelParm.FileFilter == "*")
                {
                    MessageBox.Show("删除空文件夹时不能忽略所有文件。", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    sporadicFunction.SetFileSelectParm(fileSelParm);
                    List <string> emptyFolderList = sporadicFunction.GetEmptyFolderList(fileSelParm.SourceFileFolder, fileSelParm.FileFilter);
                    emptyFolderList.Reverse();
                    StringBuilder sbMsg = new StringBuilder();
                    foreach (string empFolder in emptyFolderList)
                    {
                        sbMsg.AppendLine(empFolder);
                    }

                    if (emptyFolderList.Count > 0)
                    {
                        using (formTextMessage frmMessage = new formTextMessage("是否删除以下空文件夹?", sbMsg.ToString().Trim().TrimEnd(Environment.NewLine.ToArray()), true))
                        {
                            if (frmMessage.ShowDialog(this) == DialogResult.OK)
                            {
                                emptyFolderList.Reverse(); //重新倒置,使从子目录开始删
                                sporadicFunction.Execute_DeleteEmptyFolder(emptyFolderList);
                            }
                        }
                    }
                    else
                    {
                        CommFunction.WriteMessage("没有找到空文件夹。");
                    }
                }

                UIInProcess(false);
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
示例#3
0
        private void btnSpFunFindMisplacedPhoto_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction();
                FileSelectParm       fileSelParm      = this.GetFormFileSelParm();
                if (fileSelParm.FileFilter == string.Empty)
                {
                    fileSelParm.FileFilter = CommDefinition.ExtensionPicFile;
                }
                sporadicFunction.SetFileSelectParm(fileSelParm);

                StringBuilder sbMsg             = new StringBuilder();
                List <string> fileInWrongFolder = sporadicFunction.Execute_GetFileInWrongFolder();
                foreach (string fName in fileInWrongFolder)
                {
                    sbMsg.AppendLine(fName);
                }

                if (fileInWrongFolder.Count > 0)
                {
                    using (formTextMessage frmMessage = new formTextMessage("找到的文件列表", sbMsg.ToString().Trim().TrimEnd(Environment.NewLine.ToArray()), true))
                    {
                        frmMessage.ShowDialog(this);
                    }
                }
                else
                {
                    CommFunction.WriteMessage("没有找到此类文件。");
                }

                UIInProcess(false);
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
示例#4
0
        private void btnSpFunFindMisplacedPhoto_Click(object sender, EventArgs e)
        {
            try {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction();
                FileSelectParm fileSelParm = this.GetFormFileSelParm();
                if (fileSelParm.FileFilter == string.Empty)
                    fileSelParm.FileFilter = CommDefinition.ExtensionPicFile;
                sporadicFunction.SetFileSelectParm(fileSelParm);

                StringBuilder sbMsg = new StringBuilder();
                List<string> fileInWrongFolder = sporadicFunction.Execute_GetFileInWrongFolder();
                foreach (string fName in fileInWrongFolder)
                    sbMsg.AppendLine(fName);

                if (fileInWrongFolder.Count > 0) {
                    using (formTextMessage frmMessage = new formTextMessage("找到的文件列表", sbMsg.ToString().Trim().TrimEnd(Environment.NewLine.ToArray()), true)) {
                        frmMessage.ShowDialog(this);
                    }
                }
                else {
                    CommFunction.WriteMessage("没有找到此类文件。");
                }

                UIInProcess(false);
            }
            catch (Exception ex) {
                CommFunction.WriteMessage(ex.Message);
            }
            finally {
                UIInProcess(false);
            }
        }
示例#5
0
        private void btnSpFunFindDuplicateFilesByContent_Click(object sender, EventArgs e)
        {
            try {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction(txtConsole);
                sporadicFunction.SetFileSelectParm(this.GetFormFileSelParm());

                string fileNames = sporadicFunction.Execute_FindDuplicateFilesByContent();

                if (fileNames.Length > 0) {
                    using (formTextMessage frmMessage = new formTextMessage("找到的文件列表", fileNames, true)) {
                        frmMessage.ShowDialog(this);
                    }
                }
                else {
                    CommFunction.WriteMessage("没有找到此类文件。");
                }

                UIInProcess(false);
            }
            catch (Exception ex) {
                CommFunction.WriteMessage(ex.Message);
            }
            finally {
                UIInProcess(false);
            }
        }
示例#6
0
        private void btnSpFunDeleteEmptyFolder_Click(object sender, EventArgs e)
        {
            try {
                UIInProcess(true);

                FileSporadicFunction sporadicFunction = new FileSporadicFunction();
                FileSelectParm fileSelParm = this.GetFormFileSelParm();
                if (fileSelParm.FileFilter == "*") {
                    MessageBox.Show("删除空文件夹时不能忽略所有文件。", "Message", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else {
                    sporadicFunction.SetFileSelectParm(fileSelParm);
                    List<string> emptyFolderList = sporadicFunction.GetEmptyFolderList(fileSelParm.SourceFileFolder, fileSelParm.FileFilter);
                    emptyFolderList.Reverse();
                    StringBuilder sbMsg = new StringBuilder();
                    foreach (string empFolder in emptyFolderList)
                        sbMsg.AppendLine(empFolder);

                    if (emptyFolderList.Count > 0) {
                        using (formTextMessage frmMessage = new formTextMessage("是否删除以下空文件夹?", sbMsg.ToString().Trim().TrimEnd(Environment.NewLine.ToArray()), true)) {
                            if (frmMessage.ShowDialog(this) == DialogResult.OK) {
                                emptyFolderList.Reverse(); //重新倒置,使从子目录开始删
                                sporadicFunction.Execute_DeleteEmptyFolder(emptyFolderList);
                            }
                        }
                    }
                    else {
                        CommFunction.WriteMessage("没有找到空文件夹。");
                    }
                }

                UIInProcess(false);
            }
            catch (Exception ex) {
                CommFunction.WriteMessage(ex.Message);
            }
            finally {
                UIInProcess(false);
            }
        }