private void btnOk_Click(object sender, EventArgs e) { try { #region Checking input if (!String.IsNullOrEmpty(txtNew.Text.Trim())) { int temp = -1; if (!int.TryParse(txtNew.Text.Trim(), out temp)) { MessageBox.Show("Please enter the correct value!"); return; } } if (txtNew.Text.Trim() == txtOld.Text) { MessageBox.Show("The new refresh cycle is same as old refresh cycle!"); return; } #endregion string path = Application.StartupPath + "\\SysConfig"; string newCycle = string.Empty; if (string.IsNullOrEmpty(txtNew.Text.Trim())) { newCycle = txtOld.Text.Trim() + "," + Convert.ToString(checkBox1.Checked); } else { newCycle = txtNew.Text.Trim() + "," + Convert.ToString(checkBox1.Checked); } FileOperate.CoverOldFile(path, "RefreshCycle.txt", newCycle); MessageBox.Show("Success!"); int result = 10000; int.TryParse(newCycle.Split(',')[0], out result); changeSelectedPageTimer.Interval = result; if (checkBox1.Checked) { changeSelectedPageTimer.Start(); } else { changeSelectedPageTimer.Stop(); } this.DialogResult = DialogResult.OK; } catch (Exception ex) { logger.Error(ex.Message); } }