|
本帖最后由 被封禁言 于 2013-6-9 23:56 编辑
//简易的下载器,,,代码回复下查看,,挺简单的{:soso_e120:}大婶飘过
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.Data;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Windows.Forms;
- using System.Net;
- using System.IO;
- namespace 下载器
- {
- public partial class Form1 : Form
- {
- public Form1()
- {
- InitializeComponent();
- }
-
- private void button1_Click(object sender, EventArgs e)
- {
- string url = "http://dldir1.qq.com/qqfile/qq/QQ2013/2013Beta5/6966/QQ2013Beta5.exe";//下载地址,这里以QQ为例了
-
-
- WebClient Http = new WebClient();
- Http.Proxy = null;
- Http.DownloadFileCompleted += new AsyncCompletedEventHandler(Http_DownloadFileCompleted);
- Http.DownloadProgressChanged += new DownloadProgressChangedEventHandler(Http_DownloadProgressChanged);
- Http.DownloadFileAsync(new Uri(url), Application.StartupPath +"\" +Path.GetFileName(url));
- }
- void Http_DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e)
- {
- progressBar1.Value = e.ProgressPercentage;
- }
- void Http_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
- {
- MessageBox.Show("下载完成");
- }
- }
- }
复制代码
界面就一按钮,一进度条 |
|