0

I have a config file which has a custom section added to it. How do I access the ConnectionString field and update it? (I can't use xpath or any xml related stuff)

<?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>
marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
user1890098
  • 473
  • 2
  • 10
  • 24

1 Answers1

0

Why can't you use any xml related stuff? You might wanna consider REGEX

Haim Houri
  • 251
  • 1
  • 11
  • Why would you use regex to read well defined configuration file? – mason Dec 16 '16 at 03:37
  • @Haim I can only use methods from ConfigurationManager, pls don't ask why :) – user1890098 Dec 16 '16 at 03:43
  • @user1890098 Why? – mason Dec 16 '16 at 03:59
  • @mason I'm full aware to [this](http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454). but he specifically said that he can't use any XML related stuff. user1890098 you can enumerate through all the properties of the configuaration. if you tell me what properties are dynamic and what not I could give you a working code example – Haim Houri Dec 16 '16 at 13:16