2016-12-16 59 views
0

我有一個配置文件,其中添加了自定義部分。如何訪問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> 

回答

0

爲什麼你不能使用任何XML相關的東西? 你可能想考慮REGEX

+0

爲什麼你會使用正則表達式來讀取定義良好的配置文件? – mason

+0

@Haim我只能使用ConfigurationManager的方法,請不要問爲什麼:) – user1890098

+0

@ user1890098爲什麼? – mason

相關問題