winform下載網頁源碼

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

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

private void button2_Click(object sender, EventArgs e)
{
MessageBox.Show("各類Info快來下載吧!");
}orm

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);
}htm

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

相關文章
相關標籤/搜索