ASHX下载后删除文件

时间:2013-07-27 05:44:12

标签: asp.net .net ashx

我正在使用通用处理程序(.ashx)传输文件。

然后我需要在完成传输后删除该文件。

try{
  context.Response.ClearContent();
  context.Response.ContentType = "text/octet-stream";
  context.Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
  context.Response.TransmitFile(filePath);
  context.Response.End();  
}
finally {
  //File.Delete(filePath);
}

当我使用finally语句时,在传输完成之前删除该文件。

如何处理转移完成事件?

P.S。我不能使用global.asax或MVC。

0 个答案:

没有答案