c# - Can I modify a custom configuration section using ConfigurationManager? -
i have app.config
of form
<?xml version="1.0" encoding="utf-8"?> <configuration> <configsections> <section name="custom.config" type="system.configuration.dictionarysectionhandler, system, version=1.0.3300.0, culture=neutral, publickeytoken=b77a5c561934e089" /> </configsections> <kcura.config configsource="custom.config" /> </configuration>
with custom configuration file custom.config
of form
<?xml version="1.0" encoding="utf-8"?> <custom.config> <add key="foo" value="bar" /> </custom.config>
i've inherited code, , there no existing configurationsection
or configurationsectionhandler
associated custom.config
section.
i can access value of foo
fine
directcast(system.configuration.configurationmanager.getsection("custom.config"), system.collections.idictionary)
but update value, programatically (for testing purposes). is possible?
i've read following, , i'm still stumped; seem imply namespace reading values, not full crud:
you'll have modify custom.config
file on disk using xdocument you'll need call refreshsection
on configurationmanager
this refresh named section next time retrieved re-read disk.
Comments
Post a Comment