private void button_search_Click(object sender, EventArgs e) { richTextBox_status.Text = ""; ReplaceFileInfo info = GetInfo(); if (!check(info)) { return; } SetStatus(false); Thread thread = new Thread(new ParameterizedThreadStart(ReplaceInFilesFunction.FindString)); thread.Start(info); }
private ReplaceFileInfo GetInfo() { ReplaceFileInfo info = new ReplaceFileInfo(); info.mainForm = this; info.sourceFolder = textBox_folderPath.Text; info.files = new List <string>(); foreach (var item in checkedListBox_files.CheckedItems) { info.files.Add(item.ToString()); } info.searchText = textBox_originText.Text; info.replaceText = textBox_replaceText.Text; info.resultFolder = textBox_result.Text; return(info); }
public bool check(ReplaceFileInfo info) { if (info.sourceFolder == "") { SetRichBoxText("警告:您还未选择word文件夹!"); return(false); } if (info.files.Count == 0) { SetRichBoxText("警告:请至少选择一个word文件!"); return(false); } if (info.searchText == "") { SetRichBoxText("警告:查找字符串不能为空!"); return(false); } return(true); }
private void button_replace_Click(object sender, EventArgs e) { richTextBox_status.Text = ""; ReplaceFileInfo info = GetInfo(); if (!check(info)) { return; } if (info.resultFolder == "") { SetRichBoxText("警告:您还未设置结果文件夹!"); return; } SetStatus(false); Thread thread = new Thread(new ParameterizedThreadStart(ReplaceInFilesFunction.ReplaceString)); thread.Start(info); }