我正在读取配置文件以获取baseAddress
位于以下位置的值:
<?xml version="1.0" encoding="utf-8" ?>
<configuration>...
<system.serviceModel>
<services>
<service name="nameX" behaviorConfiguration="behaviorConfigurationX">
<host>
<baseAddresses>
<add baseAddress="http://xxx"/>
</baseAddresses>
</host>
</service>
</services>
...</configuration>
我能够找到services
配置部分,但它下面没有服务部分。这是快速观看:
如何从此配置文件中获取http://xxx ?
编辑:这是我如何加载配置文件:
string folderPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + "\\SoftOne";
string[] directories = Directory.GetDirectories(folderPath, "*" + DisplayName + "*");
if (directories.Length > 0)
{
string[] configFiles = Directory.GetFiles(directories[0], "*.config");
if (configFiles.Length > 0)
{
System.Configuration.Configuration configuration = System.Configuration.ConfigurationManager.OpenExeConfiguration(configFiles[0]);
}
}