What is the preferred method for storing user preferences in a Windows.NET application?

Forgive my ignorance, but I have never developed Windows applications. How to save user settings? Is the embedded database the preferred method?

+4
source share
4 answers

I think you are looking for custom settings :

The .NET Framework 2.0 allows you to create and access values ​​that persist between applications during executive sessions. These values ​​are called settings. Settings can represent user settings or valuable information the application needs to use. For example, you can create a series of settings that store user preferences for the color scheme of the application. Or you can save a connection string that indicates the database used by your application. Settings allow you to simultaneously save information, which is crucial for the application outside the code, and to create profiles that store the preferences of individual users.

+9
source

It depends on what settings. There are many methods in the registry from embedded databases (such as SQLite) to XML files.

  • If the settings are very few, the registry often makes sense.
  • If the settings are more complex and need to be edited manually, you can use XML or JSON files.
  • If the settings are complex and do not require manual editing, a built-in database such as SQLite, .NetBtree or BerkelyDB.NET is a good choice.
+2
source

It all depends on what size application you create. If you use something simple, say a β€œfamily shopping list,” you can save the settings in a nice old text file.

If you are building something larger, such as a classmate-notifier, you can use an XML file or some other resource.

For any larger application, you should use some kind of relational database to store user data.

+1
source

Use the Blane Pegasus library ( http://pegasus.codeplex.com/ ).

You can use its XmlSerializationHelper class, which allows you to quickly turn objects into XML and vice versa.

Or you can use isolated storage (I would provide a link to MSDN if I were not a new user and limited to a single hyperlink to the message). If you are using IsolStorage, consider using the Blane IsolatedStorageHashtable class.

+1
source

Source: https://habr.com/ru/post/1285698/


All Articles