Example #1
0
 public ReplaceTextOptions(ReplaceTextOptions RTO) : base(RTO)
 {
     SameAsInputFolder = RTO.SameAsInputFolder;
     FindWhat          = RTO.FindWhat;
     ReplaceWith       = RTO.ReplaceWith;
 }
Example #2
0
        private void btnStart_Click(object sender, EventArgs e)
        {
            ErrorFlag = false;

            if (chkDocx.Checked == false)
            {
                MessageBox.Show("Please select at least one file type", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (!Directory.Exists(txtInputFolder.Text))
            {
                MessageBox.Show("Invalid Input Folder : " + txtInputFolder.Text, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            if (txtFindWhat.Text == "")
            {
                MessageBox.Show("Empty Find Text", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }

            ReplaceTextOptions replaceTextOptions = new ReplaceTextOptions
            {
                docx = chkDocx.Checked,
                xlsx = chkXlsx.Checked,
                pptx = chkPptx.Checked,
                txt  = chkTxt.Checked,
                html = chkHtml.Checked,

                IncludeSubdirectories = chkIncludeSubdirectories.Checked,
                SameAsInputFolder     = chkSameAsInputFolder.Checked,

                InputFolder  = txtInputFolder.Text,
                OutputFolder = txtOutputFolder.Text,

                FindWhat    = txtFindWhat.Text,
                ReplaceWith = txtReplaceWith.Text
            };

            Log.CreateEntry();
            Log.CreateEntry("#", RepeatTextCount: 100);
            Log.CreateEntry("ReplaceText Operation Started");
            Log.CreateEntry("#", RepeatTextCount: 100);
            Log.CreateEntry();

            if (chkSameAsInputFolder.Checked == false)
            {
                if (txtOutputFolder.Text == "")
                {
                    MessageBox.Show("Output Folder Path is Empty", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                CopyFilesOptions copyFilesOptions = new CopyFilesOptions(replaceTextOptions);
                CopyFiles        copyFiles        = new CopyFiles();

                //try
                //{
                copyFiles.Run(copyFilesOptions);
                //}
                //catch (Exception Ex)
                //{
                //    ErrorFlag = true;
                //    Log.CreateEntry("-", RepeatTextCount: 100);
                //    Log.CreateEntry("CopyFiles: " + Ex.Message, "ERR");
                //    Log.CreateEntry("-", RepeatTextCount: 100);
                //}

                if (ErrorFlag)
                {
                    MessageBox.Show("Error Occured in Copying Files. View Log File for more Information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }

                replaceTextOptions.InputFolder = replaceTextOptions.OutputFolder;
            }

            ReplaceText replaceText = new ReplaceText(replaceTextOptions);

            //try
            //{
            replaceText.Run();
            //}
            //catch(Exception Ex)
            //{
            //    ErrorFlag = true;

            //    Log.CreateEntry("-", RepeatTextCount: 100);
            //    Log.CreateEntry("Error: " + Ex.Message, "ERR");
            //    Log.CreateEntry("-", RepeatTextCount: 100);

            //    MessageBox.Show("Error : " + Ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            //}

            if (ErrorFlag)
            {
                Log.CreateEntry();
                Log.CreateEntry("#", RepeatTextCount: 100);
                Log.CreateEntry("Replace Text Operation Finished with Errors");
                Log.CreateEntry("#", RepeatTextCount: 100);
                Log.CreateEntry();

                MessageBox.Show("Replace Text Operation Finished with Errors. View Log File for more Information", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                Log.CreateEntry();
                Log.CreateEntry("#", RepeatTextCount: 100);
                Log.CreateEntry("Replace Text Operation is Complete");
                Log.CreateEntry("#", RepeatTextCount: 100);
                Log.CreateEntry();

                MessageBox.Show("Replace Text Operation is Complete", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
Example #3
0
 public ReplaceText(ReplaceTextOptions rto)
 {
     replaceTextOptions = rto;
 }