[英]access web.config using wpf
谁能帮助我找出如何从WPF胖客户端打开web.config文件的人。 我有一个wpf表单(不是Silverlight应用程序),我希望能够浏览到目录(c:\\ test \\ web.config),然后从选定的web.config文件的appSettings部分加载自定义键。 示例将表单中的字段绑定到Path = Version
在web.config文件中,版本将标识为:
<add key="Version" value="1.0 />
提前致谢
我通常更喜欢使用类似以下一种ConfigurationManager方法:
http://msdn.microsoft.com/en-us/library/ms224437.aspx
还是有带有XPath的旧样式Xml:
XmlDocument webConfig = new XmlDocument();
webConfig.Load(dllConfigFileName);
XmlNode someNode = webConfig.SelectSingleNode("//configuration/appSettings/add[@key='someKey']");
或更新的LINQ to XML:
XDocument document = XDocument.Load(configFileFullName);
XElement configurationElement = document.Element("configuration");
XElement appSettingsElement = configurationElement.Element("appSettings");
List<XElement> configSettings = new List<XElement>(appSettingsElement.Descendants("add"));
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.