访问和更新配置文件中的自定义部分
问题描述:
我有一个配置文件,其中添加了自定义部分。如何访问ConnectionString
字段并进行更新? (我不能使用XPath或任何XML相关的东西)访问和更新配置文件中的自定义部分
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
<section name="HandleApplication"
type="Contracts.ConfigSections.HandleApplication, Contracts"/>
</configSections>
<HandleApplication>
<Handler AppId="2" ConnectionString="XXXXXXXXXXXXX"/>
</HandleApplication>
</configuration>
为什么你会使用正则表达式来读取定义良好的配置文件? – mason
@Haim我只能使用ConfigurationManager的方法,请不要问为什么:) – user1890098
@ user1890098为什么? – mason