Writing a new KEY-VALUE pair into configuration file

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi,
i have to write a new KEY VALUE pair programatically into the app.config file.

is this possible? i tried the ConfigurationSettings.AppSettings but it
raises an exception saying that Collection is Read Only.

so the question is ... upon clicking a button i want to add a new KEY VALUE
pair to the Config File.. how do i do this?

thanks
VenuGopal
 
Hi,
i have to write a new KEY VALUE pair programatically into the app.config file.

is this possible? i tried the ConfigurationSettings.AppSettings but it
raises an exception saying that Collection is Read Only.

so the question is ... upon clicking a button i want to add a new KEY VALUE
pair to the Config File.. how do i do this?

thanks
VenuGopal

Well, there seems to be a reason that it is readonly. And here is one
article on why it is a bad idea to write to app.config:

http://www.interact-sw.co.uk/iangblog/2004/11/25/savingconfig

But, if you really, really think you need to write to this file, you can
always load it into an XmlDocument object and add what you need that
way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top