再次,用户配置文件 C#
我有一个很大的配置文件(用户),我需要转到正确的位置并具有一些默认值。
由于我有一个安装程序类,我在其中的配置文件中添加了一些参数设置,但在安装程序文件夹中创建了配置文件。
确保这些默认参数仅写入一次并写入正确位置的最佳方法是什么?
I have a large config file (user) that i needed to go to the right location and have some default values.
Since i have a installer class, i added some parameter setting to the config file in it, but created the config files in the installers folder.
What is the best way to ensure these default parameters will be written only once, and in the right location?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在 app.config 中使用默认值的标准方法。例如,这是我用来确保代码在升级之间复制用户设置的每个版本的默认值:
您需要将 .settings 文件添加到您的项目中,或者转到您的项目属性 -> 。设置并从那里配置它们。
用户自己的设置文件的位置通常放置在其个人资料的 AppSettings 文件夹中。我不确定这是否可以改变,但我似乎记得读过它。
编辑
这里有一些关于它的更多信息:应用程序设置架构
如果您想保持简单,它还显示了以下示例:
这看起来在使用此(引用)时需要注意非常重要:
A standard way of using defaults in the app.config. For example, here's a default value per version I use to ensure the code copies user settings between upgrades:
You will need to add a .settings file to your project, or go to your project properties -> Settings and configure them from there.
The location of the user's own settings file is usually placed within their AppSettings folder in their profile. I'm not sure if this can be changed, but I seem to remember reading out it.
EDIT
There's some more information about it here: Application Settings Architecture
It also shows the following example if you want to keep it simple:
And this looks like it's very important to note when using this (quote):