在VB.NET项目中,我有一个xml文档作为嵌入式资源。我正在访问它与无法保存到嵌入式xml文档
Private xmlFile as New XmlDocument()
在总宣言领域。然后我加载它的形式加载方法:
xmlFile.LoadXml(My.Resources.Settings)
在一个方法我发现特定节点,并根据用户输入更新它们:
'Dim xmlDoc as XmlDocument
'xmlDoc = xmlFile
Dim settingNodes As XmlNodeList = xmlFile.SelectNodes("//Program/ProgramTitle")
For Each setting As XmlNode In settingNodes
If setting.InnerText = title Then
setting.ParentNode.Item("ProgramSaveFolder").InnerText = programFolder
setting.ParentNode.Item("PrimaryBackupFolder").InnerText = primBackup
setting.ParentNode.Item("SecondaryBackupFolder").InnerText = secBackup
End If
Next
' Neither of these work
xmlFile.Save("Settings.txt")
'xmlDoc.Save("GameSettings.txt")
的xmlDoc中的代码是从当我导致相信有一点,它不是保存,因为xmlFile正在使用(我一直在尝试很多不同的东西!)。
但是,正如代码所述,这些工作都没有。这与我所见过的有关如何执行此操作的示例非常相似,但是当我运行该程序时,它根本不会更改文件。
您从一个地方加载并保存到另一个地方 - 为什么? – OneFineDay 2015-02-05 18:56:18
你能解释一下你看到我做错了吗? – marky 2015-02-05 19:01:09
您无法在运行时修改嵌入的资源,故事结束。 – 2015-02-05 19:17:33