开发者

Where to store user preferences for a C# Windows app

开发者 https://www.devze.com 2023-02-18 20:50 出处:网络
Can anyone provide a best-practices example for where to store user preferences for a C# Windows app?

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 .NE开发者_如何学GoT 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?


  • 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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消