Marthin
Marthin

Reputation: 6543

c# save settings

Im building a small project that uses some settings features. I could change the DB Path and some other textfields.

Whats the best way in c# to save these settings? Is there some built in config or ini file that can be changed under runtime? Because if I change the DB Path i need it to do this without restarting the program. I know i ofc can build a simple textdoc and read from but I whant to use some standard c# way.

Thx for anyfeedback.

/Marthin

Upvotes: 1

Views: 3386

Answers (2)

Davide Piras
Davide Piras

Reputation: 44605

if you create a new c# windows form application you have by default the properties, try to expand the node in solution explorer, you will find the settings file where you could add your values, at runtime you could retrieve them and change them, after changing them you save them in this way:

Properties.Settings.Default.Save();

Upvotes: 0

WraithNath
WraithNath

Reputation: 18013

If you have a look in the project property pages you can add a settings file.

To use the settings in code you would do something like:

Properties.Settings.Default.SettingName

Do bare in mind though that these settings are local and would need to be specified on each machine

Here is a link to the settings class on MSDN http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx

Upvotes: 1

Related Questions