原文:http://topic.csdn.net/u/20081125/21/b05ebc85-3591-4d65-8602-66af58ef825f.html?seed=812988667
using System.Net ;
using System.IO ;

Code
/// <summary>
/// 获取网页的HTML代码
/// </summary>
/// <param name="url">Url地址(http://www.baidu.com/)</param>
/// <param name="Prog">进度条</param>
/// <returns></returns>
public static string GetUrlData(string url,ProgressBar Prog)
{
HttpWebResponse res = null;
HttpWebRequest req = (HttpWebRequest)HttpWebRequest.Create(url);
res = (HttpWebResponse)req.GetResponse();
long totalBytes = res.ContentLength;
Stream input = null;
input = res.GetResponseStream();
int totalDownloadedByte = 0;
byte[] by = new byte[10245];
string Content=null;
System.Text.Encoding encoder = System.Text.Encoding.GetEncoding("GB2312");
do
{
totalDownloadedByte = input.Read(by, 0, (int)by.Length);
Content+=encoder.GetString(by, 0, totalDownloadedByte);
if (Prog.Value + totalDownloadedByte <= Prog.Maximum)
{
Prog.Value += totalDownloadedByte;
Application.DoEvents();
}
else
{
Prog.Value = Prog.Maximum;
}
}
while (totalDownloadedByte != 0);
res.Close();
Prog.Value =0 ;
return Content;
}