0
我需要新設置手動合併年長user.config,和現在我只想老值加載到一個字典:如何自定義user.config XML加載到一個字典
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<userSettings>
<myprog.Properties.Settings>
<setting name="openkey" serializeAs="String">
<value>o</value>
</setting>
<setting name="licenseAccepted" serializeAs="String">
<value>True</value>
</setting>
代碼:
Dictionary<string, string> myDictionary = new Dictionary<string, string>();
XmlDocument document = new XmlDocument();
document.Load(OlderSettingLocation);
XmlNodeList s = document.SelectNodes("/configuration/userSettings/myprog.Properties.Settings/setting");
foreach (XmlNode node in s)
{
myDictionary.Add(node.Attributes["name"].Value, node.Attributes["value"].Value);
}
這導致node.Attributes [「名稱」]。值是「設定」,而不是在第一回路「打開項」,而和值均爲空下面
你能給出一個更完整的示例與多個設置? – jdweng