可能重复:
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);