Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-mvc/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net mvc 将XML文件保存在与自定义操作不同的目录中_Asp.net Mvc - Fatal编程技术网

Asp.net mvc 将XML文件保存在与自定义操作不同的目录中

Asp.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

如何更新以下代码以保存在IIS上我选择的目录中。目前,它将仅以路径的文件名保存在我的下载目录中

例如,以下示例保存在我的下载目录中

C--inetpub wwwroot sitename Feeds reports.xml

[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文件从当前目录移动到提要目录。我不明白您使用上述代码想要实现什么?您没有在任何地方显示如何保存文件。您能告诉我们您正在尝试做什么吗?如果要保存文件,请参阅