hard2reg
V2EX  ›  问与答

C#写下载器的问题

  •  
  •   hard2reg · Nov 28, 2017 · 1697 views
    This topic created in 3114 days ago, the information mentioned may be changed or developed.
            private void button1_Click(object sender, EventArgs e)
            {
                ServicePointManager.DefaultConnectionLimit = 1024;
                MessageBox.Show(""+ ServicePointManager.DefaultConnectionLimit);
                WebClient client = new WebClient();
                client.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback);
                client.DownloadFileTaskAsync("https://lon-gb-ipv6.vultr.com/vultr.com.1000MB.bin", "d:\\gb.bin");
                WebClient client2 = new WebClient();
                client2.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback2);
                client2.DownloadFileTaskAsync("https://par-fr-ipv6.vultr.com/vultr.com.1000MB.bin", "d:\\fr.bin");
                WebClient client3 = new WebClient();
                client3.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressCallback3);
                client3.DownloadFileTaskAsync("https://fra-de-ipv6.vultr.com/vultr.com.1000MB.bin", "d:\\de.bin");
            }
    
            private void DownloadProgressCallback(object sender, DownloadProgressChangedEventArgs e)
            {
                progressBar1.Value = e.ProgressPercentage;
            }
    
            private void DownloadProgressCallback2(object sender, DownloadProgressChangedEventArgs e)
            {
                progressBar2.Value = e.ProgressPercentage;
            }
    
            private void DownloadProgressCallback3(object sender, DownloadProgressChangedEventArgs e)
            {
                progressBar3.Value = e.ProgressPercentage;
            }
    

    为什么无法正常下载。。。。进度条飞快到达 100%

    BTW 用 WebHttpRequest 还是用 WebClient 写下载器好?

    No Comments Yet
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   4169 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 30ms · UTC 05:21 · PVG 13:21 · LAX 22:21 · JFK 01:21
    ♥ Do have faith in what you're doing.