加载自定义配置文件 [英] Loading custom configuration files

查看:127
本文介绍了加载自定义配置文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道我可以打开相关的组装与静态 ConfigurationManager.OpenExe(exePath)方法,但我只是想打开一个配置配置文件,是不是涉及到装配。只是一个标准的.NET配置文件。

I know I can open config files that are related to an assembly with the static ConfigurationManager.OpenExe(exePath) method but I just want to open a config that is not related to an assembly. Just a standard .NET config file.

推荐答案

发表瑞奇的文章都非常好,但不幸的是他们不回答你的问题。

the articles posted by Ricky are very good, but unfortunately they don't answer your question.

要解决你的问题,你应该尝试这件作品code的:

To solve your problem you should try this piece of code:

ExeConfigurationFileMap configMap = new ExeConfigurationFileMap();
configMap.ExeConfigFilename = @"d:\test\justAConfigFile.config.whateverYouLikeExtension";
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(configMap, ConfigurationUserLevel.None);

这篇关于加载自定义配置文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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