Save application preferences… registry/file?

前端 未结 2 1543
孤独总比滥情好
孤独总比滥情好 2020-12-10 09:38

Where is the best place to store application preferences?

In particular, I\'d like to save preferences for a media player such as volume levels and the like. Two ca

相关标签:
2条回答
  • 2020-12-10 10:06

    Open settings.settings in your Visual Studio solution; add an application setting (i.e. change scope from 'user' to 'application').

    The IDE creates a backing class that you can use in code.

    • Application Settings

    • Application Settings Overview

    • Using Application Settings and User Settings

    • Application Settings Architecture

    The registry should be avoided.

    The location of the app.exe.config and user.config files will differ based on how the application is installed. For a Windows Forms-based application copied onto the local computer, app.exe.config will reside in the same directory as the base directory of the application's main executable file, and user.config will reside in the location specified by the Application.LocalUserAppDataPath property. For an application installed by means of ClickOnce, both of these files will reside in the ClickOnce Data Directory underneath %InstallRoot%\Documents and Settings\username\Local Settings.

    0 讨论(0)
  • 2020-12-10 10:15

    See Application Settings for Windows Forms. Even though it is about Windows Forms, this can be used for other similar applications.

    Don't use the Registry without very good reason.

    0 讨论(0)
提交回复
热议问题