Asp.net mvc 将XML文件保存在与自定义操作不同的目录中
如何更新以下代码以保存在IIS上我选择的目录中。目前,它将仅以路径的文件名保存在我的下载目录中 例如,以下示例保存在我的下载目录中 C--inetpub wwwroot sitename Feeds reports.xmlAsp.net mvc 将XML文件保存在与自定义操作不同的目录中,asp.net-mvc,Asp.net Mvc,如何更新以下代码以保存在IIS上我选择的目录中。目前,它将仅以路径的文件名保存在我的下载目录中 例如,以下示例保存在我的下载目录中 C--inetpub wwwroot sitename Feeds reports.xml [HttpGet] public XmlActionResult GetXmlData() { System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("~/repor
[HttpGet]
public XmlActionResult GetXmlData()
{
System.Xml.XmlTextReader reader = new System.Xml.XmlTextReader(Server.MapPath("~/reports.xml"));
var xml = XElement.Load(reader);
//I want to save the file to the following destination but this saves it with the file name of the destination in my downloads directory
return new XmlActionResult(xml.ToString(), Server.MapPath("~/Feeds/reports.xml"));
}
编辑
我想将reports.xml文件从当前目录移动到feed目录。是XmlActionResult还是自定义ActionResult?如果要保存文件,为什么要返回ActionResult?XmlActionResult是一个自定义ActionResult,所以要将reports.xml文件从当前目录移动到提要目录。我不明白您使用上述代码想要实现什么?您没有在任何地方显示如何保存文件。您能告诉我们您正在尝试做什么吗?如果要保存文件,请参阅