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
 

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