吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 3340|回复: 1
收起左侧

[其他转载] C#简易的下载器

[复制链接]
neicun 发表于 2013-11-16 21:29
[C#] 纯文本查看 复制代码
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("下载完成");
        }

    }
}


界面自己设计一个按钮  一个进度条就OK了  

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

xiao589 发表于 2013-11-16 22:03
想学习C#
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-9-22 01:34

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表