473,395 Members | 1,527 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why won't my download ever end?

I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #1
12 1402
Here is the my theory.
Add ContentLength: to the header.

Response.AppendHeader("ContentLength", Filesize.tostirng() )
Let me know if it worked.
George.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #2
I appreciate the response, but that didn't do it. I was hoping it would at least address another item I posted regarding download progress, but it didn't do that either. Any other ideas?

Jerry
"George Ter-Saakov" <no****@hotmail.com> wrote in message news:Oy****************@TK2MSFTNGP11.phx.gbl...
Here is the my theory.
Add ContentLength: to the header.

Response.AppendHeader("ContentLength", Filesize.tostirng() )
Let me know if it worked.
George.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #3
FYI - This only seems to be a problem with larger downloads. The smaller downloads work just fine.
"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #4
Jerry,

If you solve this, it will be amazing. I spend days last week researching ths issue and read about developer teams spending months trying to get a solution, and finally did (but in a very messy and complex way). I hope you get it though...we will all be happy!!!

Earl

BTW, with the current solution you have so for, does the dowload dialog pop up to the client right away?

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #5
Any reason not to just use the WriteFile method?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo**************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #6
When I tried it with Response.WriteFile, larger files just ended up with a "Page Not Found" error.

The code below seems to work - there's something strange going on. I tried it with three files:

File1: 66,854K
File2: 74,902K
File3: 158,262K

Files 1 and 3 work without a problem. File 2 hangs every time. This is really making me crazy! What's the problem with 74 Meg if you can handle 158 Meg just fine?

Anyone? Please!?!??!?!

Jerry
"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message news:O8****************@tk2msftngp13.phx.gbl...
Any reason not to just use the WriteFile method?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo**************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #7
The dialog seems to pop up pretty quickly. Why? Is that another known issue?

How do I get ahold of the "very messy and complex way"?

Jerry
"Earl Teigrob" <ea******@hotmail.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Jerry,

If you solve this, it will be amazing. I spend days last week researching ths issue and read about developer teams spending months trying to get a solution, and finally did (but in a very messy and complex way). I hope you get it though...we will all be happy!!!

Earl

BTW, with the current solution you have so for, does the dowload dialog pop up to the client right away?

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #8
And just to make things even more frustrating, File2 works from another workstation. I wonder if I've got some IE security patch on this box that doesn't like files with specific byte counts...
"Jerry Camel" <rl*****@msn.com> wrote in message news:%2********************@TK2MSFTNGP11.phx.gbl.. .
When I tried it with Response.WriteFile, larger files just ended up with a "Page Not Found" error.

The code below seems to work - there's something strange going on. I tried it with three files:

File1: 66,854K
File2: 74,902K
File3: 158,262K

Files 1 and 3 work without a problem. File 2 hangs every time. This is really making me crazy! What's the problem with 74 Meg if you can handle 158 Meg just fine?

Anyone? Please!?!??!?!

Jerry
"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message news:O8****************@tk2msftngp13.phx.gbl...
Any reason not to just use the WriteFile method?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo**************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #9
Read this

http://www.dotnetjunkies.com/Article...2E50CBFA..dcik
"Jerry Camel" <rl*****@msn.com> wrote in message news:uw****************@TK2MSFTNGP10.phx.gbl...
The dialog seems to pop up pretty quickly. Why? Is that another known issue?

How do I get ahold of the "very messy and complex way"?

Jerry
"Earl Teigrob" <ea******@hotmail.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Jerry,

If you solve this, it will be amazing. I spend days last week researching ths issue and read about developer teams spending months trying to get a solution, and finally did (but in a very messy and complex way). I hope you get it though...we will all be happy!!!

Earl

BTW, with the current solution you have so for, does the dowload dialog pop up to the client right away?

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #10
WriteFile blows up when using very large files (500m+). It tries to buffer the entire file to the server before sending, gives no notice to the user, takes forever and finally crashed the server. A slight problem...
"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message news:O8****************@tk2msftngp13.phx.gbl...
Any reason not to just use the WriteFile method?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo**************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #11
When using Writefile, the entire file is cached to the server before the dialog box is displayed, which can take a long time on large files...(if the server does not crash, of course)
"Jerry Camel" <rl*****@msn.com> wrote in message news:uw****************@TK2MSFTNGP10.phx.gbl...
The dialog seems to pop up pretty quickly. Why? Is that another known issue?

How do I get ahold of the "very messy and complex way"?

Jerry
"Earl Teigrob" <ea******@hotmail.com> wrote in message news:%2******************@TK2MSFTNGP11.phx.gbl...
Jerry,

If you solve this, it will be amazing. I spend days last week researching ths issue and read about developer teams spending months trying to get a solution, and finally did (but in a very messy and complex way). I hope you get it though...we will all be happy!!!

Earl

BTW, with the current solution you have so for, does the dowload dialog pop up to the client right away?

"Jerry Camel" <rl*****@msn.com> wrote in message news:uo****************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my page. I was having issues with large files, but after much research I came up with the following code. The download seems to proceed without issue, but never terminiates. The byte count stops incrementing, but the dowload dialog never closes. (Until I hit cancel.) What's keeping the download from ending properly? I'm pretty close to finishing this app - any help is greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(), FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to download?
Thanks again!

- Jerry
Nov 18 '05 #12
did you try to use smaller chunks (I have used 2k chunks but I had low user
load and files not really getting over 70Mb)... maybe that could help. If
not, probably you should go with the dotnetjunkies method of using
ISAP+HttpHandler

"Earl Teigrob" <ea******@hotmail.com> wrote in message
news:%2******************@TK2MSFTNGP09.phx.gbl...
WriteFile blows up when using very large files (500m+). It tries to buffer
the entire file to the server before sending, gives no notice to the user,
takes forever and finally crashed the server. A slight problem...
"Eric Lawrence [MSFT]" <e_********@hotmail.com> wrote in message
news:O8****************@tk2msftngp13.phx.gbl...
Any reason not to just use the WriteFile method?

--
Thanks,

Eric Lawrence
Program Manager
Assistance and Worldwide Services

This posting is provided "AS IS" with no warranties, and confers no rights.

"Jerry Camel" <rl*****@msn.com> wrote in message
news:uo**************@tk2msftngp13.phx.gbl...
I thought I had finally figured out how to control the downloads from my
page. I was having issues with large files, but after much research I came
up with the following code. The download seems to proceed without issue,
but never terminiates. The byte count stops incrementing, but the dowload
dialog never closes. (Until I hit cancel.) What's keeping the download
from ending properly? I'm pretty close to finishing this app - any help is
greatly appreciated. Thanks.

Dim fStream As FileStream
Dim bytesToGo As Long
Dim bytesRead As Long
Dim byteBuffer(1048576) As Byte

fStream = New FileStream("C:\DepotRoot\" & e.CommandArgument(),
FileMode.Open, _
FileAccess.Read, FileShare.Read)
bytesToGo = fStream.Length
Response.BufferOutput = False
Response.Clear()
Response.ClearContent()
Response.ClearHeaders()
Response.ContentType = "application/octet-stream"
Response.AppendHeader("Content-Disposition", "attachment; filename=""" & _
dr("FileName") & """")
Response.Flush()
While (bytesToGo > 0)
If (Response.IsClientConnected) Then
bytesRead = fStream.Read(byteBuffer, 0, 1048576)
Response.OutputStream.Write(byteBuffer, 0, bytesRead)
Response.Flush()
bytesToGo -= bytesRead
Else
bytesToGo = -1
End If
End While

Response.Flush() 'This is kinda redundant, but it was worth a shot.
fStream.Close() 'Close the stream on the server side.
Response.End() 'Shouldn't this tell the browser to stop trying to
download?
Thanks again!

- Jerry
Nov 18 '05 #13

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
1
by: Dave | last post by:
Hi Everyone, I was wondering if anyone has ever successfully used SA-FileUp's download feature. I am being forced to change from "ASPSmartUpload" as the server I am moving everything to is...
4
by: Hitesh | last post by:
Hi, I am having a requirement where in user can click on a link and the download popup appears and then user should be redirected to a congratulations page. We didn't bother whether the...
2
by: Ken Spreitzer | last post by:
Hi, all. Quick question -- hopefully just a "yes" or "no". Will a user ever download a (separate) file with the extension ".manifest" when using *any* facet of .NET (ie, ASP.NET, WinForms, web...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.