我想与 xsl(样式表)一起下载 xml 文件。我下载xml文件的代码如下:
XPathDocument myXPathDoc = new XPathDocument("myxml.xml");
XslCompiledTransform myXslTrans = new XslCompiledTransform();
myXslTrans.Load("myxsl.xsl");
XmlTextWriter myWriter = new XmlTextWriter("Result.html", null);
myXslTrans.Transform(myXPathDoc, null, myWriter);
string strFullPath = Server.MapPath("Result.html");
string strContents = null;
System.IO.StreamReader objReader = default(System.IO.StreamReader);
objReader = new System.IO.StreamReader(strFullPath);
strContents = objReader.ReadToEnd();
objReader.Close();
//attach that XML file and download on local machine
string attachment = "attachment; filename=" + myWriter;
Response.ClearContent();
Response.ContentType = "text/html";
Response.AddHeader("content-disposition", attachment);
Response.Write(strContents);
我在谷歌搜索过,但找不到解决方案。给出一些关于这个的想法但是它给出的例外是进程无法访问文件'~mypath\Result.html',因为它正在被另一个进程使用。