471,349 Members | 2,018 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,349 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 2507
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Hugh McLaughlin | last post: by
reply views Thread by Amol Guttal via .NET 247 | last post: by
4 posts views Thread by Richard L Rosenheim | last post: by
1 post views Thread by Rajiv Barik | last post: by
1 post views Thread by Richard K Bethell | last post: by
5 posts views Thread by rony_16 | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.