How to manage generated files, how long to keep them using asp.net

superbus

New Member
I have a web application that generates excel files from a template.When the new file is streamed to the client I deleted the file. This works fine in my computer, but for whatever reason, when accesing the website from another computer, the file is deleted before streamed to the client, so the file is always empty (0 bytes)Here is the code:\[code\]try{ Response.Clear(); Response.ClearHeaders(); Response.ContentType = "application/ms-excel"; Response.AddHeader("content-disposition", "attachment;filename=" + newFN + ".xlsx"); Response.TransmitFile(DestFile); Response.Flush(); Response.End();}finally{ File.Delete(DestFile);}\[/code\]Why this works fine from my computer, and it doesn't from another computer?What can I do to delete generated files and when? I'm thinking in having like a schedule task, to check by date, all files before specific date, and delete them, but is there any other solution?
 
Back
Top