472,993 Members | 3,153 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,993 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 2753
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: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

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.