保存应用程序preferences ...注册表/文件? [英] Save application preferences... registry/file?

查看:174
本文介绍了保存应用程序preferences ...注册表/文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里存储应用程序preferences最好的地方?

Where is the best place to store application preferences?

在我特别想对媒体播放器节省preferences比如音量水平等。两名候选人映入脑海......文件和注册表。这将是比较合适?

In particular, I'd like to save preferences for a media player such as volume levels and the like. Two candidates spring to mind... file and registry. Which would be more appropriate?

作为后续行动这一点,我也想知道是否有任何的API,帮助创建应用程序特定设置。

As a follow up to this, I'm also wondering if there are any APIs that aid in creating application specific settings.

除非有人建议我,这是不对的,我想保存的东西无论是在 HKCU ...或HKLM /软件/ MyCompanyName / MyAppName /键的注册表,或%APPDATA \ MyCompanyName \ MyAppName \ someTypeOfSettingsFile

Unless someone advises me that this is wrong, I'd like to save stuff either in HKCU... or HKLM/Software/MyCompanyName/MyAppName/Key for the registry, or in %APPDATA\MyCompanyName\MyAppName\someTypeOfSettingsFile.

由于这些似乎常用于这样的设置,我认为净可以很容易地存储在这些地方设置。有一个简单的高层次的API,可以净给我来读写设置这些常见的位置?

As these seem to be commonly used for such settings, I'd assume that .Net makes it easy to store settings in these locations. Is there a simple high level API that can .Net offer me to read and write settings to these common locations?

推荐答案

在Visual Studio解决方案打开 settings.settings ;添加一个应用程序的设置(从用户到应用程序,即变化幅度)。

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

IDE将创建,您可以在code使用支持类。

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

应用程序设置概述

使用应用程序设置和用户设置

应用程序设置架构

应避免注册表。

的app.exe.config的位置和   user.config文件将不同根据   如何安装应用程序。对于   一个基于Windows窗体的应用   复制到本地计算机上,   app.exe.config将驻留在同一   目录中的基本目录   应用程序的主执行文件,   和user.config将驻留在   位置指定的   Application.LocalUserAppDataPath   属性。用于安装的应用程序   借助于的ClickOnce的,这两个   文件将驻留在的ClickOnce   数据目录下   %InstallRoot%\ Documents和   Settings \用户名\ Local设置。

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.

这篇关于保存应用程序preferences ...注册表/文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆