/// <summary> 获取界面文件过滤勾选项 /// </summary> /// <returns></returns> private FileSelectParm GetFormFileSelParm() { FileSelectParm retVal = new FileSelectParm(); if (rdoTypePic.Checked) { retVal.FileFilter = CommDefinition.ExtensionPicFile; } else if (rdoTypeAudio.Checked) { retVal.FileFilter = CommDefinition.ExtensionAudioFile; } else if (rdoTypeVideo.Checked) { retVal.FileFilter = CommDefinition.ExtensionVideoFile; } else if (rdoTypeText.Checked) { retVal.FileFilter = CommDefinition.ExtensionTextFile; } else if (rdoTypeCust.Checked) { retVal.FileFilter = txtFileType.Text; } if (rdoSortName.Checked) { retVal.FileSortBy = FileSortMode.FileName; } else if (rdoSortCreateDate.Checked) { retVal.FileSortBy = FileSortMode.CreateDate; } else if (rdoSortModifyDate.Checked) { retVal.FileSortBy = FileSortMode.ModifyDate; } else if (rdoSortRecordDate.Checked) { retVal.FileSortBy = FileSortMode.RecordingDate; } else if (rdoSortNameDate.Checked) { retVal.FileSortBy = FileSortMode.DateInFileName; } retVal.SourceFileFolder = txtSourceFolder.Text; retVal.TargetFileFolder = txtTargetFolder.Text; retVal.UseSpecFileList = chkSpecFileList.Checked; retVal.SpecFileList = _fileChangeNameSpecChgFileList; retVal.FileTypeIsIgnore = chkIsIgnoreFileType.Checked; return(retVal); }
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); } }
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); } }
private FileSelectParm GetFormFileSelParm() { FileSelectParm retVal = new FileSelectParm(); if (rdoTypePic.Checked) retVal.FileFilter = CommDefinition.ExtensionPicFile; else if (rdoTypeAudio.Checked) retVal.FileFilter = CommDefinition.ExtensionAudioFile; else if (rdoTypeVideo.Checked) retVal.FileFilter = CommDefinition.ExtensionVideoFile; else if (rdoTypeText.Checked) retVal.FileFilter = CommDefinition.ExtensionTextFile; else if (rdoTypeCust.Checked) retVal.FileFilter = txtFileType.Text; if (rdoSortName.Checked) retVal.FileSortBy = FileSortMode.FileName; else if (rdoSortCreateDate.Checked) retVal.FileSortBy = FileSortMode.CreateDate; else if (rdoSortModifyDate.Checked) retVal.FileSortBy = FileSortMode.ModifyDate; else if (rdoSortRecordDate.Checked) retVal.FileSortBy = FileSortMode.RecordingDate; else if (rdoSortNameDate.Checked) retVal.FileSortBy = FileSortMode.DateInFileName; retVal.SourceFileFolder = txtSourceFolder.Text; retVal.TargetFileFolder = txtTargetFolder.Text; retVal.UseSpecFileList = chkSpecFileList.Checked; retVal.SpecFileList = _fileChangeNameSpecChgFileList; retVal.FileTypeIsIgnore = chkIsIgnoreFileType.Checked; return retVal; }
public void SetFileSelectParm(FileSelectParm fileSelectParm) { this.FileSelParm = fileSelectParm; }