i am using vb.net for windows application.
i want o know to update the custom tag in config file.
in app config file initially i stored
empty string. after my application run time i will replace the
empty string into
some value.
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<configSections>
<section name="tagx" type="System.Configuration.NameValueSectionHandler" />
</configSections>
<tagx>
<add key="key1" value=""/>
</tagx>
</configuration>
after run my application i want to update the key1 value as "KING".
i searched in net, all the examples giving how to update the appsettings tag value only.
i
NO need appsettings updation. i want to update custom tag value.
thanks.
What I have tried:
Dim configFile = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None)
Dim settings = CType(configFile.GetSection("tagx"), AppSettingsSection).Settings
settings("key1").Value = "KING"
configFile.Save(ConfigurationSaveMode.Modified) ConfigurationManager.RefreshSection(configFile.AppSettings.SectionInformation.Name)
but it raise the exception in
Dim settings = CType(configFile.GetSection("tagx"), AppSettingsSection).Settings
unable to cast defaultsettings into appsettings