downloading zip file using webResponse

G

Guest

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
 
G

Gabriel Lozano-Morán

Have you tried downloading the file from a local webserver?

Gabriel Lozano-Morán
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top