您的位置:首页 > 编程语言 > C#

C#如何调用其他.config配置文件,就是2个乃至3个以上的config文件

2016-03-22 19:28 344 查看
XmlDocument xDoc = new XmlDocument();
try
{
xDoc.Load(配置文件路径);
XmlNode xNode;
XmlElement xElem;
xNode = xDoc.SelectSingleNode("//appSettings");    //补充,需要在你的app.config 文件中增加一下,<appSetting> </appSetting>
xElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + 读取的配置KEY+ "']");
if (xElem != null)
return xElem.GetAttribute("value");
else
return "";
}
catch (Exception)
{
return "";
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: