我在同一个解决方案下有两个项目。 我想更改项目的 app.config 的值,但我不知道该怎么做
项目 A
项目 B
它们应该这样运行: 项目 A 是一个编码的 UITest,我想更改它的配置文件的值。
这是我试过的方法
string abc = @"absolutePath\app.config";
Configuration configuration = ConfigurationManager.OpenExeConfiguration(abc);
configuration.AppSettings.Settings["areaCode"].Value = "new";
configuration.Save();
ConfigurationManager.RefreshSection("appSettings");
我要修改的项目的app.config是一个.dll(codedUiTestProject)
这是我的节点结构:
<appSettings>
<add key="LogFilePath" value="" />
<add key="areaCode" value="steamAccessDummy"/>
</appSettings>
我需要一些帮助,谢谢! 还有其他解决方案吗?
最佳答案
你试过configuration.Save(ConfigurationSaveMode.Full, true);
关于c# - 在运行时更改其他项目的 app.config 值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30015807/