可以在运行时切换 app.config 吗? [英] Is switching app.config at runtime possible?

查看:29
本文介绍了可以在运行时切换 app.config 吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在运行时切换应用程序 app.config(current.config 到 new.config,文件换文件).我有一个备份/恢复过程,需要替换它自己的 application.exe.config 文件.我看过这个post 但它没有回答如何在运行时执行此操作.

Is there a way at runtime to switch out an applications app.config (current.config to new.config, file for file). I have a backup/restore process which needs to replace its own application.exe.config file. I have seen this post but it does not answer how to do this at runtime.

推荐答案

原来我可以将 .config 文件换成新的,并为每个部分执行 ConfigurationManager.RefreshSection(...).它将从新的 .config 文件更新.

Turns out I can swap the .config file for the new one and do a ConfigurationManager.RefreshSection(...) for each section. It will update from the new .config file.

这篇关于可以在运行时切换 app.config 吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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