I have the following code which takes in a string representing an element in my settings/config file. It then returns the value of that element.
This all works fine but what I need to do is create this setting with a string "NOT AVAILABLE"if it is not there.Code:public string GetAppConfigValue(string SettingName) { string sContents; ConfigurationSectionGroup grpApp = config.GetSectionGroup("applicationSettings"); ClientSettingsSection secPropSet = (ClientSettingsSection)grpApp.Sections[sSettingsSection]; secPropSet.SectionInformation.ForceSave = true; SettingElement elm = secPropSet.Settings.Get(SettingName); if (elm == null) { sContents = SettingName + " is missing!"; } else { sContents = elm.Value.ValueXml.InnerText.Trim(); } return sContents; }
I think its something along the lines off :
The above code adds this to the config "<setting name="NEW_ATTRIBUTE" serializeAs="String" />" but it has no value and no closing tag " </setting>"Code:SettingElement newElem = new SettingElement(SettingName, SettingsSerializeAs.String); secPropSet.Settings.Add(newElem); //How do i add "NOT AVAILABLE" to its value
Man am I ever confused :-(





Reply With Quote