deleting temp file after HttpResponse.WriteFile

V

Vadim

Hi,

I will have to send a file to a user's browser to be opened in a Save, Open
manner, I am using HttpResponse.WriteFile for this, the info to be sent will
have to be first accumulated in a temp file in a temp directory and sent to
a user and then I would want to delete the temp file. Please let me know if
the following sequence will be correct:

HttpResponse.WriteFile(TempFileName)
HttpResponse.End
DeleteTempFile //Is it safe to delete tempfile here or the call to
httpResponse.writefile might still be doing something on another thread
internally, etc...

Thank you

Vadim
 
C

CJ

I would do something like this..

try{
HttpResponse.WriteFile(TempFileName)
// you may also need to .flush() here
HttpResponse.End
}finally{
if(tempfile.exists) deletetempfilehere..
}

that way, no matter what happens, the temp file gets deleted
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,619
Members
45,316
Latest member
naturesElixirCBDGummies

Latest Threads

Top