microkarl
Well-known member
Hi all,
I have implemented some code in my page that will generate a .txt file (on the fly) when the user click on an ASP button, then a download box will show up and so the user can download that file. But I want to delete the file right away after the file is finished downloading...
can anyone give me some hint?
Thanks,
Carl
I have implemented some code in my page that will generate a .txt file (on the fly) when the user click on an ASP button, then a download box will show up and so the user can download that file. But I want to delete the file right away after the file is finished downloading...
//Heres the code to generate the file... Everything ends @Response.End();
System.IO.FileInfo fileToDownload = new System.IO.FileInfo(myFileName);
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + myFileName);
Response.ContentType = "application/octet-stream";
Response.WriteFile(myFileName);
Response.End();
//I tried to change it to become the following, but still doesnt work...
//Response.Close();
//fileToDownload.Delete();
can anyone give me some hint?
Thanks,
Carl