473,395 Members | 2,079 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.

downloading zip file using webResponse

hi ,
I am trying to download a zip file from a http site using webResponse .
here's the code
WebRequest wReq ;
wReq = WebRequest.Create(wUri ) ;
wReq.Credentials = new NetworkCredential (_uid,_psswd);
wReq.Timeout = 6000000;
WebResponse wRes = wReq.GetResponse();
Stream wOutput = wRes.GetResponseStream();
BinaryReader br = new BinaryReader (wOutput);
FileStream fs = new FileStream (_saveLocation + _filename,FileMode.Create );
BinaryWriter writer = new BinaryWriter (fs );
byte bWr ;

while(true)
{
try
{
bWr = br.ReadByte();
writer.Write(bWr);
}
catch(EndOfStreamException ex)
{
break;
}
}

This works fine to download file for 2 - 3 MB but when it comes to
download 5 - 6 MB files it encountres endOFstreamexception at around 2 - 3 MB
and doesn't download the complete file .
can any one help me to rectify this problem .
Thanks and Regards,
Rajiv

Jul 21 '05 #1
1 2840
Have you tried downloading the file from a local webserver?

Gabriel Lozano-Morán

"Rajiv Barik" <Rajiv Barik @discussions.microsoft.com> wrote in message
news:7C**********************************@microsof t.com...
hi ,
I am trying to download a zip file from a http site using webResponse .
here's the code
WebRequest wReq ;
wReq = WebRequest.Create(wUri ) ;
wReq.Credentials = new NetworkCredential (_uid,_psswd);
wReq.Timeout = 6000000;
WebResponse wRes = wReq.GetResponse();
Stream wOutput = wRes.GetResponseStream();
BinaryReader br = new BinaryReader (wOutput);
FileStream fs = new FileStream (_saveLocation +
_filename,FileMode.Create );
BinaryWriter writer = new BinaryWriter (fs );
byte bWr ;

while(true)
{
try
{
bWr = br.ReadByte();
writer.Write(bWr);
}
catch(EndOfStreamException ex)
{
break;
}
}

This works fine to download file for 2 - 3 MB but when it comes to
download 5 - 6 MB files it encountres endOFstreamexception at around 2 - 3
MB
and doesn't download the complete file .
can any one help me to rectify this problem .
Thanks and Regards,
Rajiv

Jul 21 '05 #2

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

Similar topics

1
by: Hugh McLaughlin | last post by:
Hello everyone and thanks for your help in advance. I am working on an application that allows a user to downlad a zip file from an FTP site. I have used the following code: Dim URL As String...
0
by: Amol Guttal via .NET 247 | last post by:
(Type your message here) -------------------------------- From: Amol Guttal Hi, This is the code which used to download a file from webserver. If I point a file in my localhost for download...
4
by: Richard L Rosenheim | last post by:
I know that I can download a file from a web server by using the WebClient.DownloadFile method. But, does anyone know of an example of downloading a file from a web server with the ability to...
1
by: Rajiv Barik | last post by:
hi , I am trying to download a zip file from a http site using webResponse . here's the code WebRequest wReq ; wReq = WebRequest.Create(wUri ) ; wReq.Credentials = new NetworkCredential...
8
by: jdhancock | last post by:
Can someone give me an example of how I can execute a program on a corporate server and then download the response to the user? I'm not sure if I'm asking this right. Here is the asp code used...
1
by: Richard K Bethell | last post by:
From what I am reading, a System.Net.WebRequest can be set to retrieve just parts of a file in the WebResponse, using the .AddRange method to specify a byte range. This would be very useful for me...
1
by: Hexman | last post by:
Code below ---- I'm trying to save some specific web pages to disk as text files. I searched the Internet and found a basic example which I changed to fit my needs. I tested it out first on a...
5
by: rony_16 | last post by:
Hi, I have a problem downloading a file . after i connect to the website and get the stream , i treing to write the file on the HD. public void SaveStreamToFile(string filePath, Stream stream) {...
7
by: raids51 | last post by:
Hello, i have a program that downloads a file using the httpwebrequest/response, and it usually works, but sometimes it will freeze at a random part of the download without an error. here is the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.