C# 更新后如何保存xml资源文件?

C# 更新后如何保存xml资源文件?,c#,xmldocument,C#,Xmldocument,我使用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

我使用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\u info”抛出错误。

您可以用于此任务

下面是来自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);
  }