C#写下载器的问题

2017-11-28 13:38:25 +08:00
 hard2reg
        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 写下载器好?

1347 次点击
所在节点    问与答
0 条回复

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/410181

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX