//create a web Httprequest
HttpWebRequest wReq = (HttpWebRequest)HttpWebRequest.Create("http://www.wrox.com/Support/PDF/SampleChapter_5091.pdf");
//set the address and port of the proxy server
WebProxy wp = new WebProxy("211.114.193.234",8080);
//set the web request's proxy server
wReq.Proxy=wp;
//create a web Httpresponse
HttpWebResponse wResp = (HttpWebResponse)wReq.GetResponse();
//write the response to a stream
Stream respStream = wResp.GetResponseStream();
//create a new file to receive the response stream
localStream = new FileStream("SampleChapter_5091.pdf", FileMode.Append, FileAccess.Write);

BinaryReader reader = new BinaryReader(respStream);
//set the receive binary buffer
const int BufferSize = 102400;
byte[] buffer = new Byte[BufferSize];
bool bFinished = false;
int dataRead;
//just write the buffer to the binaryReader again and again
do
{
try
{
dataRead = reader.Read(buffer,0,BufferSize);
if (dataRead==0)
bFinished = true;
localStream.Write(buffer,0,dataRead);
}
catch
{
localStream.Close();
respStream.Close();
}
}while(!bFinished);
//close all file stream
localStream.Close();
respStream.Close();
ShowLog("Download finished");
}