C#下载并删除文件

时间:2013-01-03 12:38:40

标签: c# file download

  

可能重复:
  When can I delete a file after using it in Response.WriteFile()?

我正在使用以下代码下载临时文件然后将其删除但是,最后一条语句没有被执行,我该怎么办呢

Response.ContentType = "application/octet-stream";
Response.AddHeader("Content-Disposition", "attachment; filename=" + sFileName);
Response.Clear();
Response.WriteFile(sFilePath);
//Response.WriteFile(Server.MapPath(sFilePath));            
Response.End();
File.Delete(sFilePath);

0 个答案:

没有答案