TimothyP
TimothyP

Reputation: 21745

Add User Settings at runtime in a c# application

I want to add new settings to the user.config at runtime for a C# application (WPF). These settings will be added by independent modules so I have no idea what they will be in advance.

Most examples refer to:

Configuration config =
    configurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);

But this only allows you to access the Application Settings and you can't save it anyway as it's not meant to be modified.

I want to be able to do something like

Settings.Default.Add("SomeKey", "someobject");
Settings.Default.Save()

after which this setting would be available the next time this specific user starts the application.

Upvotes: 3

Views: 3016

Answers (1)

Jan
Jan

Reputation: 36

You may wish to check this solution.

It is doable but it is lots of code.

Upvotes: 2

Related Questions