hard2reg
V2EX  ›  问与答

C#写下载器的问题

  •  
  •   hard2reg · Nov 28, 2017 · 1699 views
    This topic created in 3115 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   ·   2925 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 34ms · UTC 15:18 · PVG 23:18 · LAX 08:18 · JFK 11:18
    ♥ Do have faith in what you're doing.