try
{
XElement contactsFromFile = XElement.Load("App_Data/EmployeeFinList.xml");
var xEle = new XElement("Employees",
from emp in ListFromBasicPay
select new XElement("Employee",
new XAttribute("EmpID", emp.employee_personal_id),
new XElement("GrandTotal", emp.grandTotal),
new XElement("Housing", emp.housing),
new XElement("BasePay", emp.base_pay),
new XElement("XchangeRate", emp.Exchange_rate)));
xEle.Save("..\\changesetDB.xml");
Debug.WriteLine("Converted to XML");
}
catch (Exception ex)
{
Debug.WriteLine(ex.Message);
}
我想将xml文件保存在我在我的项目中创建的文件夹中。然后,我将使用在我的文件夹中创建的xml文件并从中读取和写入。任何想法如何做到这一点?在项目文件夹中保存XML文件
你想把它添加到你的项目下的解决方案目录吗? – 2013-02-25 17:18:32
是的!我在我的解决方案中有两个项目,一个用于UI,另一个包含我的linq到实体分支。我想将它保存在我的解决方案目录中 – 2013-02-25 17:20:14
什么是您想要保存这个'xEle.Save(“.. \\ changesetDB.xml”)的确切路径;''通常您应该能够执行以下操作 'xEle .Save(“changesetDB.xml”);'但是你应该捕获你试图保存这个文件的路径 – MethodMan 2013-02-25 17:21:27