如何编辑应用程序配置设置?App.config 最好的方法是什么? [英] How to edit application configuration settings? App.config best way to go?

查看:26
本文介绍了如何编辑应用程序配置设置?App.config 最好的方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于我的项目,我通过项目属性中的设置添加了设置.

For my project I have settings that I added through the Settings in the project properties.

我很快发现直接编辑 app.config 文件似乎并没有真正更新设置值.似乎我在进行更改然后重新编译时必须查看项目属性.

I quickly discovered that editing the app.config file directly seems to no really update the settings value. Seems I have to view the project properties when I make a change and then recompile.

  • 我想知道......什么是最好的最简单的方法来处理可自定义的设置对于一个项目——认为这会毫不费力地了解 .Net处理它......我感到羞耻.

  • I'm wondering ... what is the best and easiest way to handle customizable settings for a project -- thought this would be a no-brainer with how .Net handles it ... shame on me.

是否可以使用其中一种设置,应用设置ApplicationSettingsUserSettings 来处理这个问题?

Is it possible to use one of the settings, AppSettings, ApplicationSettings, or UserSettings to handle this?

将我的设置写入自定义配置文件并自己处理是否更好?

Is it better to just write my settings to custom config file and handle things myself?

现在...我正在寻找最快的解决方案

我的环境是 C#、.Net 3.5 和 Visual Studio 2008.

更新

我正在尝试执行以下操作:

I am trying to do the following:

    protected override void Save()
    {
        Properties.Settings.Default.EmailDisplayName = this.ddEmailDisplayName.Text;
        Properties.Settings.Default.Save();
    }

编译时出现只读错误.

推荐答案

这很愚蠢……我想我必须为浪费大家的时间而道歉!但看起来我只需要将范围设置为用户而不是应用程序,我就可以写入新值.

This is silly ... and I think I am going to have to apologize for wasting everyone's time! But it looks like I just need to set the scope to User instead of Application and I can the write the new value.

这篇关于如何编辑应用程序配置设置?App.config 最好的方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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