.NET is the best way to save application settings

Possible duplicate:
What is the best way to store user preferences for a .NET application?

Hello. What is the best way to store application settings in .NET 4.0? Windows registry? Application.Settings?

What if I want to be able to update the program and save the settings from the old version (the new version may have newer settings and some old ones are deleted)?

What if I want to keep a collection of my custom objects?

I know there is a similar question, but this is about .Net 2.0. There may be several new ways to save your settings in 4.0.

Thanks in advance.

+4
source share
3 answers

MS is trying to get people out of the registry on the latest 2 OS versions. In addition, as @Scott Anderson noted in his comment, .Net 4.0 has not changed in this regard.

If this is a local application without backup data storage, then continue to use the app.config file.

If you want to store local data, I would recommend using something like sql lite or a similar mechanism in which you can easily create tables and query them as needed. It will also help in version control.

+1
source

I do not think .NET 4 has added anything new regarding application settings.

See what's new in .Net 4. http://msdn.microsoft.com/en-us/library/ms171868.aspx

+1
source

Application.Settings is, of course, the way to go - unlike registry settings, it will work regardless of the operating system, user level, or when starting the application from the Terminal Services client.

In the past, I created the MigrateUserSettings property and used it to help me manage the migration of user settings.

I set this property to true in the default application. On startup, if I find that it is ever set to true , I try to migrate the parameters and then set it to false (then it remains false strong> until the application is updated).

Example:

if (Settings.Default.MigrateUserSettings) { Settings.Default.Upgrade(); Settings.Default.MigrateUserSettings = false; /* Custom handling of migrating specific settings (if required) here eg if any have been renamed or if the possible options have changed. */ Settings.Default.Save(); } 
+1
source

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


All Articles