adding new settings to user.config at run time in C#

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

Guest

Hi,

I've tried the following code to add new settings to the user.config file at
run time but it does not actually save the new settting in the file. It's
only there for this session.

SettingsProperty hostDefaultSetting = new SettingsProperty("host" +
i.ToString());
hostDefaultSetting.PropertyType = typeof(String);
hostDefaultSetting.DefaultValue = cmbHost.Text;
Properties.Settings.Default.Properties.Add(hostDefaultSetting);
Properties.Settings.Default.Save();

Is it possible to add new user settings at run time at all in C#?

Best regards,
Hans Jivesten
 
Back
Top