Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Hi All,

 

I need to be able to parse the settings in app.config and change some of them.

Then have .NET persisit the changes back to the user.config file since the properties I want to change are user scope. Below is the approach I am taking.

 

// Get the properties object

Properties.Settings appSettings = ProgramName.Properties.Settings.Default;

 

// Get the properties collection

SettingsPropertyCollection SettingsCollection = ProgramName.Properties.Settings.Default.Properties;

 

// get a couple of property objects from the collection

System.Configuration.SettingsProperty Day = zeusSettingsCollection["The_Day"];

System.Configuration.SettingsProperty Year = zeusSettingsCollection["The_Year"];

 

// change the values

Day.DefaultValue = "Set in Program";

Year.DefaultValue = "Set in Program";

 

// save the changes

appSettings.Save();

 

This is not working.

 

Thanks in advance.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...