如何仅将文件保存在temp文件夹中,现在我的文件既保存在临时文件夹中,又保存在下载文件夹中。
Response.ContentType = "application/pdf";
Response.AddHeader("content-disposition", "attachment;filename=Default.pdf");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
//string filePath = Path.Combine(Path.GetTempPath(), "Default.pdf");
StringWriter sw = new StringWriter();
HtmlTextWriter hw = new HtmlTextWriter(sw);
this.Page.RenderControl(hw);
StringReader sr = new StringReader(sw.ToString());
Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 100f, 0f);
HTMLWorker htmlparser = new HTMLWorker(pdfDoc);
string path = Path.GetTempPath();
FileStream stream = new FileStream(path + "/Default.pdf",FileMode.Create);
PdfWriter.GetInstance(pdfDoc,stream);
pdfDoc.Open();
htmlparser.Parse(sr);
pdfDoc.Close();
stream.Close();
Response.Write(pdfDoc);
Response.End();
文件应仅打开并保存在临时文件夹中