3

我正在使用 C# 像这样附加 xml 资源文件。

XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(Properties.Resources.setup_info);
XmlNode node = xmlDoc.SelectSingleNode("data/Ename");
node.Attributes[1].Value = "true";

在此之后我需要保存资源文件。但

xmlDoc.Save(path);//needs the file path

如果我给出“Properties.Resources.setup_info”抛出错误。

4

1 回答 1

0

你可以使用ResourceWriter 来完成这个任务

这是来自 MSDN 的示例代码

using System;
using System.Resources;


public class WriteResources {
   public static void Main(string[] args) {

      // Creates a resource writer.
      IResourceWriter writer = new ResourceWriter("myResources.resources");

      // Adds resources to the resource writer.
      writer.AddResource("String 1", "First String");

      writer.AddResource("String 2", "Second String");

      writer.AddResource("String 3", "Third String");

      // Writes the resources to the file or stream, and closes it.
      writer.Close();
   }
}

下面会将xml写入资源文件ProjXML.resources

  using (ResourceWriter rw = new ResourceWriter(@".\ProjXML.resources"))
  {
     rw.AddResource("MyXML",  xmlDoc.OuterXml);
  }
于 2013-05-11T05:17:47.747 回答