473,325 Members | 2,480 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,325 software developers and data experts.

Error while downloading large files

Dear Sirs,

When I try to download large documents I receive the following error
"unable to read data from the transport connection". How can I solve this?

Regards,
Yahya

Private Sub DownloadImage(ByVal strSrcURI As String, ByVal localfilepath As
String, ByVal BufferSize As Integer)

Dim buffers() As Byte

Dim MyCredentialCache As System.Net.CredentialCache

ReDim buffers(BufferSize)

Dim wr As WebRequest = WebRequest.Create(strSrcURI)

' This stream does not support seeking, so it cannot return length.

' so allocate enough memory to save the binary image data.

MyCredentialCache = New System.Net.CredentialCache

MyCredentialCache.Add(New System.Uri(strSrcURI), _

"NTLM", _

New System.Net.NetworkCredential(strUserName, strPassword, strDomain) _

)

' Create the HttpWebRequest object.

wr = CType(System.Net.WebRequest.Create(strSrcURI), _

System.Net.HttpWebRequest)

' Add the network credentials to the request.

wr.Credentials = MyCredentialCache

Dim stream As Stream = wr.GetResponse().GetResponseStream()

Dim BytesToRead As Integer = CType(buffers.Length, Integer)

Dim BytesRead As Integer = 0

Dim n As Integer = 0

Do

n = stream.Read(buffers, BytesRead, BytesToRead)

BytesToRead -= n

BytesRead += n

Loop While n > 0

stream.Close()

Dim fs As FileStream = New FileStream(localfilepath, FileMode.Create)

fs.Write(buffers, 0, BytesRead)

fs.Close()

End Sub
Nov 21 '05 #1
0 879

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

Similar topics

0
by: sales | last post by:
If you are having difficulty downloading large files, please check out www.Downloads4Dialups.com. Mention this newsgroup in the "Special Instructions" window on the Shipping Form, and receive a...
0
by: Rhon Stewart via DotNetMonster.com | last post by:
Hi please visit this link : http://www.eggheadcafe.com/articles/pfc/selfupdater.asp I followed all the steps for listed on the link , when I execute the application it it gives me the following...
4
by: whoopdaddy | last post by:
We are streaming a PDF file out of an ASPX page in IIS 5 using Response.WriteFile so the user does not need permissions to the directory where the files are stored. This works great when the user is...
0
by: hoenes1 | last post by:
Hi all, I'm trying to send files to a client following the instructions of http://support.microsoft.com/?id=812406 Everything works fine, but if files are large and/or if the bandwidth is...
10
by: mwt | last post by:
This code works fine to download files from the web and write them to the local drive: import urllib f = urllib.urlopen("http://www.python.org/blah/blah.zip") g = f.read() file =...
4
by: PiotrKolodziej | last post by:
hi I have a thread that downloades a file. Problem is : Not all files are beeing downloaded. I observed that only the small files are beeing downloaded correctly. I also cant download two files...
7
by: Steve | last post by:
Hello, I am a beginner/intermediate c++ coder. I have a program that I am writing and would like to be able to distribute to some of my friends. The problem with this is that the data files...
6
by: cyusman | last post by:
Hi, We have just moved our application to a new webfarm server environment which utilizing hardware load balancing, SSL off-loading and HTTP compression off-loading.My application is running on...
0
by: =?Utf-8?B?VmFuZXNzYQ==?= | last post by:
Hi all! I am having problems on installing .NET Framework 3.5 on some machines. In one machine the error is: WinVerifyTrust returned -2146762751 Wintrust not on machine Error: O arquivo...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.