这是我的配置文件:
<configuration>
<configSections>
<sectionGroup name="API">
<section name="loginURL" type="System.Configuration.SingleTagSectionHandler"/>
</sectionGroup>
</configSections>
<API>
<loginURL url="http://myurl/api/sd?" param1="p1=" param2="p2=" />
</API>
</configuration>
这不是应用程序的默认app.config,所以我这样打开它:
ExeConfigurationFileMap fileMap = new ExeConfigurationFileMap
{
ExeConfigFilename = strConfigPath //path to my config file
};
Configuration config = ConfigurationManager.OpenMappedExeConfiguration(fileMap, ConfigurationUserLevel.None);
ConfigurationSection mySection = config.GetSection("API/loginURL");
但是我无法像使用默认app.config一样将ConfigurationSection强制转换为Hastable:
Hashtable section1 = (Hashtable)ConfigurationManager.GetSection("API/loginURL");
string repUrl = section1["url"].ToString() + section1["param1"].ToString() +
name + section1["param2"].ToString() + password;
如何像使用默认的app.config为repUrl那样构造我的部分的哈希表?