App.Config and .NET 2.0

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

Guest

I read that 2.0 Supports modifying the App.Config however I dont see its true
and I still get an exception when trying to add a new key.

if(firstTime)
ConfigurationManager.AppSettings.Add("FirstName", "John");

can anyone hep with this issue. I dont want to go pure XML on this.
 
Will this do the trick...

Configuration configuration = ConfigurationManager.OpenExeConfiguration(
ConfigurationUserLevel.None );

AppSettingsSection section = configuration.GetSection( "appSettings" ) as
AppSettingsSection;

section.Settings.Add( "Hello", "World" );

configuration.Save();

HTH

Glenn
 

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