downloaded file is missing

  • Thread starter Thread starter ntm
  • Start date Start date
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
 
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
 
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
 
Back
Top