作者在 2009-07-07 20:42:24 发布以下内容
using System.Net;
using System.IO;
private void button1_Click(object sender, EventArgs e)
{
string URL=textBox1.Text;
try
{
this.Text=URL+"......下载中";
client.DownloadFile(URL, textBox3.Text);
MessageBox.Show("下载成功......","成功");
this.Text="D/U Loader";
}
catch(WebException exp)
{
MessageBox.Show(exp.Message,"错误");
}
FileStream filestr = new FileStream(textBox3.Text, FileMode.OpenOrCreate, FileAccess.Write);
filestr.Close();
MessageBox.Show("下载结束....", "成功");
}
private void button3_Click(object sender, EventArgs e)
{
saveFileDialog1.InitialDirectory = "C:\\";//默认路径
saveFileDialog1.Filter = "Html(*.html)|*.html|All Files (*.*)|*.*";
saveFileDialog1.FilterIndex = 1;
if (saveFileDialog1.ShowDialog() == DialogResult.OK)
{
textBox3.Text = saveFileDialog1.FileName;
}
}