473,804 Members | 3,021 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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(1048 576) As Byte

fStream = New FileStream("C:\ DepotRoot\" & e.CommandArgume nt(), FileMode.Open, _
FileAccess.Read , FileShare.Read)
bytesToGo = fStream.Length
Response.Buffer Output = False
Response.Clear( )
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/octet-stream"
Response.Append Header("Content-Disposition", "attachment ; filename=""" & _
dr("FileName") & """")
Response.Flush( )
While (bytesToGo > 0)
If (Response.IsCli entConnected) Then
bytesRead = fStream.Read(by teBuffer, 0, 1048576)
Response.Output Stream.Write(by teBuffer, 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 1432
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_********@hot mail.com> wrote in message news:O8******** ********@tk2msf tngp13.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.co m> wrote in message news:uo******** ******@tk2msftn gp13.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(1048 576) As Byte

fStream = New FileStream("C:\ DepotRoot\" & e.CommandArgume nt(), FileMode.Open, _
FileAccess.Read , FileShare.Read)
bytesToGo = fStream.Length
Response.Buffer Output = False
Response.Clear( )
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/octet-stream"
Response.Append Header("Content-Disposition", "attachment ; filename=""" & _
dr("FileName") & """")
Response.Flush( )
While (bytesToGo > 0)
If (Response.IsCli entConnected) Then
bytesRead = fStream.Read(by teBuffer, 0, 1048576)
Response.Output Stream.Write(by teBuffer, 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.co m> wrote in message news:uw******** ********@TK2MSF TNGP10.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******@hotma il.com> wrote in message news:%2******** **********@TK2M SFTNGP11.phx.gb l...
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.co m> wrote in message news:uo******** ********@tk2msf tngp13.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(1048 576) As Byte

fStream = New FileStream("C:\ DepotRoot\" & e.CommandArgume nt(), FileMode.Open, _
FileAccess.Read , FileShare.Read)
bytesToGo = fStream.Length
Response.Buffer Output = False
Response.Clear( )
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/octet-stream"
Response.Append Header("Content-Disposition", "attachment ; filename=""" & _
dr("FileName") & """")
Response.Flush( )
While (bytesToGo > 0)
If (Response.IsCli entConnected) Then
bytesRead = fStream.Read(by teBuffer, 0, 1048576)
Response.Output Stream.Write(by teBuffer, 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+HttpHandle r

"Earl Teigrob" <ea******@hotma il.com> wrote in message
news:%2******** **********@TK2M SFTNGP09.phx.gb l...
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_********@hot mail.com> wrote in message
news:O8******** ********@tk2msf tngp13.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.co m> wrote in message
news:uo******** ******@tk2msftn gp13.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(1048 576) As Byte

fStream = New FileStream("C:\ DepotRoot\" & e.CommandArgume nt(),
FileMode.Open, _
FileAccess.Read , FileShare.Read)
bytesToGo = fStream.Length
Response.Buffer Output = False
Response.Clear( )
Response.ClearC ontent()
Response.ClearH eaders()
Response.Conten tType = "applicatio n/octet-stream"
Response.Append Header("Content-Disposition", "attachment ; filename=""" & _
dr("FileName") & """")
Response.Flush( )
While (bytesToGo > 0)
If (Response.IsCli entConnected) Then
bytesRead = fStream.Read(by teBuffer, 0, 1048576)
Response.Output Stream.Write(by teBuffer, 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
6130
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 downloads. It uses fpassthru() and some headers() to send a file to the requesting user. The get.php file that I wrote (the file download module if you will) works like a charm for .ZIP files and .TXT files. However, when .EXE files are downloaded...
1
7208
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 using SAFileUp version 3.2. I ran through their documentation and found a section called "secure download", unfortunately, their examples do not work at all! On Netscape 7, the file "pretends" to download (after changing the file
4
2703
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 download is successful or not but as soon as user clicks on the download link the popup appears, and then the user should be directed to the congratulations page. I have written the standard code to download the file but after that i am
2
1069
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 service, etc)? More specifically, if I parse the web server log files for a server which either uses ASP.NET or is hosting some other .NET-based component, will I ever run across a file with an extension of ".manifest"? Or are .manifest files...
0
9706
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10082
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7622
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6854
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4301
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3822
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2995
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.