Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the preferred method for storing user settings in a .NET windows application?

Tags:

c#

.net

winforms

Pardon my ignorance, but I've never really developed Windows applications. How do you store user settings? Is an embedded database the preferred method?

like image 772
Esteban Araya Avatar asked Dec 13 '22 04:12

Esteban Araya


2 Answers

I think you are looking for user settings:

The .NET Framework 2.0 allows you to create and access values that are persisted between application execution sessions. These values are called settings. Settings can represent user preferences, or valuable information the application needs to use. For example, you might create a series of settings that store user preferences for the color scheme of an application. Or you might store the connection string that specifies a database that your application uses. Settings allow you to both persist information that is critical to the application outside of the code, and to create profiles that store the preferences of individual users.

like image 77
Andrew Hare Avatar answered Mar 11 '23 13:03

Andrew Hare


It depends on what kind of settings. There are a variety of methods from embedded databases (like SQLite) to XML files, to the Registry.

  • If the settings are very few, the registry often makes sense.
  • If the settings are more complicated, and need to be hand edited, you can use XML files or JSON.
  • If the settings are complex and do not need hand editing, an embedded database like SQLite, .NetBtree, or BerkelyDB .NET are good choices.
like image 23
Christopher Avatar answered Mar 11 '23 13:03

Christopher