winform下载网页源码

public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void button1_Click(object sender, EventArgs e)
{
this.backgroundWorker1.RunWorkerAsync();
}

private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("各种Info快来下载吧!");
}

private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e)
{
for (int i = 30000; i < 30030; i++)
{
WebClient client = new WebClient();
try
{
client.DownloadFile(@"http://job.cnblogs.com/offer/" + i + "/", @"E:\html\" + i + ".html");
}
catch { }
}
//Action是委托
Action action = new Action(msg);
this.Invoke(action);
}

private void msg()
{
MessageBox.Show("下载完成!");
}
}

posted @ 2013-06-18 11:58  奇奇博客  阅读(273)  评论(0编辑  收藏  举报