public void Save() { string errorMessage = null; if (!HROne.CommonLib.FileIOProcess.IsFolderAllowWritePermission(AppDomain.CurrentDomain.BaseDirectory, out errorMessage)) { throw new Exception(errorMessage); } string filename = getFilename(); System.Configuration.ConfigXmlDocument config = new System.Configuration.ConfigXmlDocument(); XmlElement settings = config.CreateElement("Settings"); XmlAttribute version = config.CreateAttribute("Version"); version.Value = "2.0"; settings.Attributes.Append(version); config.AppendChild(settings); SetDatabaseConfigList(settings); settings.AppendChild(config.CreateElement("ShutdownAfterUsed")); settings["ShutdownAfterUsed"].InnerText = ShutDownDomainAfterUsed ? "true" : "false"; settings.AppendChild(config.CreateElement("AllowMultiDB")); settings["AllowMultiDB"].InnerText = AllowMultiDB ? "true" : "false"; config.Save(filename); }
private void m_btnConfirm_Click(object sender, System.EventArgs e) { try { string strConfigFilePath = Application.ExecutablePath + ".config"; System.Configuration.ConfigXmlDocument appConfig = new System.Configuration.ConfigXmlDocument(); appConfig.Load(strConfigFilePath); appConfig["configuration"]["appSettings"].SelectSingleNode("add[@key=\"Preference_frmReportInput_BatchConfirmStyle\"]").Attributes["value"].Value = this.m_chkUseBatchConfirmStyle.Checked.ToString(); appConfig["configuration"]["appSettings"].SelectSingleNode("add[@key=\"Preference_frmReportInput_AutoPrint\"]").Attributes["value"].Value = this.m_chkAutoPrint.Checked.ToString(); appConfig.Save(strConfigFilePath); } catch (Exception ex) { } }