문제

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?

도움이 되었습니까?

해결책

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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top