Пример #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 btnChgNmEditChangeList_Click(object sender, EventArgs e)
 {
     using (formTextMessage frmMessage = new formTextMessage("编辑文件更名列表", _fileChangeNameChangeList)) {
         if (frmMessage.ShowDialog(this) == DialogResult.OK)
             _fileChangeNameChangeList = frmMessage.FormMessage;
     }
 }
Пример #3
0
        private void btnChgNmViewChgFileNameList_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);
                FileBatchChangeName fileBatchChangeName = ConstructFileBatchChangeName();
                List <string>       targetNameList      = fileBatchChangeName.GetTargetNameList();
                UIInProcess(false);

                if (targetNameList.Count > 0)
                {
                    string nameAll = targetNameList.Aggregate("", (current, name) => current + name + Environment.NewLine).TrimEnd(Environment.NewLine.ToCharArray());

                    using (formTextMessage frmMessage = new formTextMessage("更名列表预览", nameAll, true))
                    {
                        frmMessage.ShowDialog(this);
                    }
                }
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
Пример #4
0
        private void btnViewFileNameList_Click(object sender, EventArgs e)
        {
            try
            {
                UIInProcess(true);

                FileProcessBaseClass fileProcBase = new FileProcessBaseClass();
                fileProcBase.SetFileSelectParm(this.GetFormFileSelParm());
                string fileList = fileProcBase.LoadFileList();

                UIInProcess(false);

                if (fileList.Length > 0)
                {
                    using (formTextMessage frmMessage = new formTextMessage("文件列表预览", fileList, true))
                    {
                        frmMessage.ShowDialog(this);
                    }
                }
            }
            catch (Exception ex)
            {
                CommFunction.WriteMessage(ex.Message);
            }
            finally
            {
                UIInProcess(false);
            }
        }
Пример #5
0
 private void btnChgNmEditChangeList_Click(object sender, EventArgs e)
 {
     using (formTextMessage frmMessage = new formTextMessage("编辑文件更名列表", _fileChangeNameChangeList))
     {
         if (frmMessage.ShowDialog(this) == DialogResult.OK)
         {
             _fileChangeNameChangeList = frmMessage.FormMessage;
         }
     }
 }
Пример #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);
            }
        }
Пример #7
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);
            }
        }
Пример #8
0
        private void btnChgNmViewChgFileNameList_Click(object sender, EventArgs e)
        {
            try {
                UIInProcess(true);
                FileBatchChangeName fileBatchChangeName = ConstructFileBatchChangeName();
                List<string> targetNameList = fileBatchChangeName.GetTargetNameList();
                UIInProcess(false);

                if (targetNameList.Count > 0) {
                    string nameAll = targetNameList.Aggregate("", (current, name) => current + name + Environment.NewLine).TrimEnd(Environment.NewLine.ToCharArray());

                    using (formTextMessage frmMessage = new formTextMessage("更名列表预览", nameAll, true)) {
                        frmMessage.ShowDialog(this);
                    }
                }
            }
            catch (Exception ex) {
                CommFunction.WriteMessage(ex.Message);
            }
            finally {
                UIInProcess(false);
            }
        }
Пример #9
0
        private void btnViewFileNameList_Click(object sender, EventArgs e)
        {
            try {
                UIInProcess(true);

                FileProcessBaseClass fileProcBase = new FileProcessBaseClass();
                fileProcBase.SetFileSelectParm(this.GetFormFileSelParm());
                string fileList = fileProcBase.LoadFileList();

                UIInProcess(false);

                if (fileList.Length > 0) {
                    using (formTextMessage frmMessage = new formTextMessage("文件列表预览", fileList, true)) {
                        frmMessage.ShowDialog(this);
                    }
                }
            }
            catch (Exception ex) {
                CommFunction.WriteMessage(ex.Message);
            }
            finally {
                UIInProcess(false);
            }
        }
Пример #10
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);
            }
        }
Пример #11
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);
            }
        }
Пример #12
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);
            }
        }