private void сохранитьКакToolStripMenuItem_Click(object sender, EventArgs e) { SaveFileDialog saveFileDialog1 = new SaveFileDialog(); saveFileDialog1.InitialDirectory = AppConf.conf.LastSavedConfFile; saveFileDialog1.Filter = "Conf files (*.cnf)|*.cnf| All files (*.*)|*.*"; saveFileDialog1.FilterIndex = 1; saveFileDialog1.RestoreDirectory = true; if (saveFileDialog1.ShowDialog() == DialogResult.OK) { try { AppConf.conf.LastSavedConfFile = saveFileDialog1.FileName; SaveConfClass TempSave = new SaveConfClass(AppConf.conf.LastSavedConfFile); TempSave.conf.CurrentParam = AppConf.conf.CurrentConf; TempSave.Save(); this.FormName = "Синхронизация и копирование"; } catch (Exception ex) { ErrorWorkProc.ErrorProcess(ex); } } ; }
private void открытьToolStripMenuItem_Click(object sender, EventArgs e) { OpenFileDialog openFileDialog1 = new OpenFileDialog(); openFileDialog1.Filter = "Conf files (*.cnf)|*.cnf| All files (*.*)|*.*"; openFileDialog1.FilterIndex = 1; openFileDialog1.CheckFileExists = true; openFileDialog1.CheckPathExists = true; openFileDialog1.RestoreDirectory = true; openFileDialog1.InitialDirectory = AppConf.conf.LastSavedConfFile; if (openFileDialog1.ShowDialog() == DialogResult.OK) { if (File.Exists(openFileDialog1.FileName)) { try { SaveConfClass TempSave; // сохраняем текущий файл конфигурации if (File.Exists(AppConf.conf.LastSavedConfFile)) { TempSave = new SaveConfClass(AppConf.conf.LastSavedConfFile); // присваиваем сохраняемой конфигурации новые параметры TempSave.conf.CurrentParam = AppConf.conf.CurrentConf; TempSave.Save(); } //теперь открываем новую конфигурацию AppConf.conf.LastSavedConfFile = openFileDialog1.FileName; TempSave = new SaveConfClass(AppConf.conf.LastSavedConfFile); AppConf.conf.CurrentConf = TempSave.conf.CurrentParam; InitializeForm(); } catch (Exception ex) { ErrorWorkProc.ErrorProcess(ex); } } } ; }
private void сохранитьToolStripMenuItem_Click(object sender, EventArgs e) { if (File.Exists(AppConf.conf.LastSavedConfFile)) { try { SaveConfClass TempSave = new SaveConfClass(AppConf.conf.LastSavedConfFile); // присваиваем сохраняемой конфигурации новые параметры TempSave.conf.CurrentParam = AppConf.conf.CurrentConf; TempSave.Save(); this.FormName = "Синхронизация и копирование"; } catch (Exception ex) { ErrorWorkProc.ErrorProcess(ex); } } else { сохранитьКакToolStripMenuItem_Click(null, null); } }