Im creating a site for pathology lab in which i have to provide user with the facility to download their reports.
Im creating a zip file(ICSharpCode.SharpZipLib.dll) in which reports are added but i am uanble to delete that zip file after user has downloaded the file..
can u give me idea on which event i have to write the code for deleting the zip file
my code is as follow..
FastZip fx = new FastZip();
fx.CreateZip(path , directory, false, ".pdf$");
Response.AddHeader("content-Disposition", "Attachment;filename="+ "report.zip");
Response.WriteFile(path + "report.zip");
Response.ContentType = "Application/Zip";
Response.End();
System.IO.File.Delete(path + "report.zip");
on tracing i found that after response.end() the file deleting code is not executed.
VulpesPosted Apr 16, 2011, 4:55 PM
Suthish NairPosted Apr 18, 2011, 2:24 PM
I digged out this link from my collection.
Good one...
meh lPosted Apr 17, 2011, 12:13 AM
Sam HobbsPosted Apr 16, 2011, 3:17 PM
Use a try/catch block to catch errors. Also look at the SharpZipLib documentation for what you need to do to check for errors. Programmers often don't want to bother to check for errors and then when something goes wrong they get more serious errors. Also look at the SharpZipLib documentation to ensure that you are closing the file and doing all other functions such as disposing the file. You might need to dispose the SharpZipLib object but do that only in the manner that the documentation describes.