User-335504541 posted
<g class="gr_ gr_13 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation only-ins replaceWithoutSep" id="13" data-gr-id="13">Hi</g> <g class="gr_ gr_14 gr-alert gr_spell gr_inline_cards gr_run_anim ContextualSpelling ins-del multiReplace" id="14" data-gr-id="14">ocammu</g>,
I think you could try to use WebConfigurationManager to find the value section of the applicationSettings.
Then replace it with a new one.
Please try to use the following code. It works.
var configFile = WebConfigurationManager.OpenWebConfiguration("~");
ClientSettingsSection section = (ClientSettingsSection)configFile.SectionGroups["applicationSettings"].Sections[0];
var value = section.Settings;
SettingElement settingElement = new SettingElement();
SettingValueElement settingValueElement = new SettingValueElement();
XmlDocument doc = new XmlDocument();
doc.Load(Server.MapPath("~/Web.config"));
XmlNodeList nodeList;
XmlNode root = doc.DocumentElement;
nodeList = root.SelectNodes("applicationSettings");
var valuenode = nodeList[0].SelectNodes("ProjectName.Properties.Settings/setting/value")[0];
var oldValue = valuenode.InnerText;
valuenode.InnerText = "New Value1";
settingValueElement.ValueXml = valuenode;
settingElement.Value = settingValueElement;
value.Clear();
value.Add(settingElement);
configFile.Save();
Best Regards,
Billy