ConfigurationManager.AppSettings - How to modify and save?

后端 未结 9 1525
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 05:10

It might sound too trival to ask and I do the same thing as suggested in articles, yet it doesn\'t work as expected. Hope someone can point me to the right direction.

<
9条回答
  •  臣服心动
    2020-11-28 05:54

    On how to change values in appSettings section in your app.config file:

    config.AppSettings.Settings.Remove(key);
    config.AppSettings.Settings.Add(key, value);
    

    does the job.

    Of course better practice is Settings class but it depends on what are you after.

提交回复
热议问题