コード例 #1
0
        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);
        }
コード例 #2
0
        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);
        }
コード例 #3
0
 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);
 }
コード例 #4
0
        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);
        }