我可以使用ConfigurationManager修改自定义配置部分吗?

时间:2017-08-14 22:15:35

标签: c# asp.net

我有databaseReference.orderByChild('_searchLastName') .startAt(queryText) .endAt(queryText+"\uf8ff") .addValueEventListener ... 表格

App.config

使用表单

的自定义配置文件<?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>
Custom.config

我已继承此代码,并且此<?xml version="1.0" encoding="utf-8"?> <Custom.Config> <add key="foo" value="bar" /> </Custom.Config> 部分没有与ConfigurationSectionConfigurationSectionHandler相关联。

我可以使用

访问Custom.Config的值
foo

但是现在我想以编程方式更新这个值(用于测试目的)。 这可能吗?

我已经阅读了以下内容,我仍然感到难过;他们似乎暗示这个命名空间只用于读取值,而不是完整的CRUD:

1 个答案:

答案 0 :(得分:0)

您必须使用XDocument修改磁盘上的Custom.config文件,然后您需要致电ConfigurationManager

上的RefreshSection

这将刷新命名部分,以便下次检索它时将从磁盘重新读取。

相关问题