downloaded file is missing

N

ntm

I am using the following ASPC.VB code to download a text file:

Response.Clear()
Response.ContentType = "ignore/this" ' arbitrary
Response.AddHeader("Content-Disposition",
"attachment;filename=file.txt")
Response.WriteFile(tempFileName)
Response.Flush()
Response.End()

I get the open/save/cancel dialog box on the Browser side. If I
select save, I see a brief download window and the the Save As dialog
box appears and I can save the file successfully. But if I select
open, I get the brief download window and then Notebook launches but a
Notebook error appears with the message:

"Cannot find the C:\Documents and Settings\Nick\Local
Settings\Temporary Internet Files\Content.IE5\03RJISDH\file[1].txt
file."

It's as if the file was downloaded but deleted before it could be
opened by Notebook.

I'd appreciate any help you can offer.

Nick
 
K

Ken Cox [Microsoft MVP]

Strange. This works for me. Was it buffering?

Private Sub Button1_Click _
(ByVal sender As System.Object, _
ByVal e As System.EventArgs) _
Handles Button1.Click
Dim tempFileName As String
tempFileName = Server.MapPath("file.txt")
Response.Buffer = True
Response.Clear()
Response.ContentType = "ignore/this" ' arbitrary
Response.AddHeader("Content-Disposition", _
"attachment;filename=file.txt")
Response.WriteFile(tempFileName)
Response.Flush()
Response.End()
End Sub
 
N

ntm

Ken Cox said:
Strange. This works for me. Was it buffering?

Ken,

Thanks very much for trying this yourself - I appreciate the effort.

I eventually tried a reboot which solved the problem, but left me
feeling very unsatisfied about what was happening. I guess I should
have tried the reboot before posting but I've gotten away from that
old habit with the more recent versions of Windows (lesson learned).

I'll see if the problem crops up again.

And again, thanks.

Nick
 

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,756
Messages
2,569,540
Members
45,025
Latest member
KetoRushACVFitness

Latest Threads

Top