[英]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.