Question

Can anyone provide a best-practices example for where to store user preferences for a C# Windows app?

So far I've heard a number of options:

  • Some people are saying to store it in SQLite. Is SQLite bundled with .NET 2.0 and immediately available for use to me?

  • Others have said to use the built-in Application Settings... but I've heard that the per-user settings here disappear if you upgrade the app (an obvious problem).

  • I've also considered just storing it in a .xml file somewhere on disk... but where it the "correct" place to store that .xml file for the user?

Was it helpful?

Solution

  • SQLite is not included with .NET2, but you could ship it with your application
  • The built-in settings system works fine for simple apps - you do need to add a couple of lines of boilerplate to deal with version changes but it's not complicated.
  • You could put your xml file here:

    Environment.GetFolderPath( Environment.SpecialFolder.LocalApplicationData)

There is a lot of 'it depends' about your question, as you don't say how much of what types of data you need to store, nor if you have any other reasons to care where it goes.

OTHER TIPS

The per-user settings "disappearing" can be solved thus: .NET ApplicationSettingsBase Should I call Upgrade() every time I load?

Storing user application settings in isolated storage seems to be a best practice.

http://msdn.microsoft.com/en-us/library/system.io.isolatedstorage(v=vs.80).aspx

Storing settings as an xml file is perfectly fine.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top