在c#中创建一个xml文档,并将该文件存储到项目的bin文件夹中

Sea*_*her 3 c# linq-to-xml

我想创建一个xml文件.我知道如何使用linq to xml概念创建一个xml文件.但我想将该文件保存在我项目的bin文件夹中.怎么做.

 XDocument changesetDB = new XDocument(
                    new XElement("changes",
                            new XElement("change",
                                new XAttribute("path", changedFile),
                                new XAttribute("changesetID", changesetID),
                                new XAttribute("JIRAID", issueID))));
Run Code Online (Sandbox Code Playgroud)

现在我想将它保存在bin文件夹中.是否可以这样做.谢谢,

Pra*_*ana 6

试试:XmlDocument.Save方法(String)

string path =  Path.GetDirectoryName(Application.ExecutablePath) ;
changesetDB .Save( Path.Combine( path , "data.xml"));
Run Code Online (Sandbox Code Playgroud)