Link to home
Start Free TrialLog in
Avatar of MonMusc
MonMusc

asked on

C# ConfigurationManager Write Existing Custom Section

So I have an application that I need to have a portable configuration file for.  I have started using the ConfigurationManager object for this, and have gotten it to read an existing Custom Section, and even create a default one if there is no Custom Section meeting my name, but I can't seem to figure out how to be able to write changed values to an existing Custom Section using ConfigurationManager.  I would like to allow the user to update values as needed without editing the .config XML directly, and so far I only see that I can do this using the AppSettings section.  Anyone have an idea of how to do this using ConfigurationManager?
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

you probably using something like:

 SectionType st = (SectionType)onfigurationManager.GetSection(“<section>”);

where  SectionType is your custom section wrapper class.
if you create the properties with both get and set you should be able to update your custom sections.
Avatar of MonMusc
MonMusc

ASKER

So looking at that, I would assume the thinking is that using the GetSection will create a object based on the App.Config CustomSection, and if I do a set to the property it will store it?  I'm curious because I specifically have to do an AddSection to do the initial write, but alas I will give it a shot and see if this leads me down the right path.
post the config and wrapper class for the custom section and i'll take a look
Avatar of MonMusc

ASKER

Attached is the cs and config file.
Config.cs
App.config
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of MonMusc

ASKER

Didn't think about that, it's working though so wondering if white space really bothers it much...
License_Reporter is the name of the project/dll so it does matters.
any specific reason for grading this as B?