I dont get this.
I have figured out how to read then update settings in my app.config at run time using the following exert:
This works fine with custom sections but not with <connectionStrings>.Code:Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None); ConfigurationSectionGroup grpApp = config.GetSectionGroup("applicationSettings"); ClientSettingsSection secPropSet = (ClientSettingsSection)grpApp.Sections[sSettingsSection]; secPropSet.SectionInformation.ForceSave = true; SettingElement elm = secPropSet.Settings.Get(SettingName); elm.Value.ValueXml.InnerText = NewValue.Trim(); config.Save()
Reading the connection strings can be done using the following exert :
For the life of me I cannot figure out how to write an update made against a connection string.Code://conn strings ConnectionStringsSection connStringSection = config.ConnectionStrings; ConnectionStringSettingsCollection connectionStringsCollection = connStringSection.ConnectionStrings; System.Collections.IEnumerator connStringsEnum = connectionStringsCollection.GetEnumerator(); int i = 0; while (connStringsEnum.MoveNext()) { ///blah blah }





Reply With Quote