Save and reload app.config(applicationSettings) at runtime
Solution 1:
You need to make a call to ConfigurationManager.RefreshSection in order to have the values re-read from disk.
Solution 2:
I did a some tests and here is result.
For auto generated class Settings
the call of ConfigurationManager.RefreshSection("applicationSettings");
doesn't apply the modified values for members marked with ApplicationScopedSettingAttribute
, it applies the changes to future calls via ConfigurationManager
members (and not sure about UserScopedSettingAttribute
).
Instead call Settings.Default.Reload();
Solution 3:
What you want is accomplish able by creating an custom ConfigSection which allows you more control and allows you to change the name. Configuration manager has a refresh section which will allow you reload the data.