菜单 学习猿地 - LMONKEY

VIP

开通学习猿地VIP

尊享10项VIP特权 持续新增

知识通关挑战

打卡带练!告别无效练习

接私单赚外块

VIP优先接,累计金额超百万

学习猿地私房课免费学

大厂实战课仅对VIP开放

你的一对一导师

每月可免费咨询大牛30次

领取更多软件工程师实用特权

入驻
81
0

WebClient,DownloadFileAsync,DownloadProgressChanged

原创
05/13 14:22
阅读数 65449
static void Main(string[] args)
        {
            WebClientDownloadProgressChanged();
            Console.ReadLine();
        }

        static void WebClientDownloadProgressChanged()
        {
            string url = "https://download.microsoft.com/download/d/1/c/d1c74788-0c6b-4d23-896e-67cf849d31ed/SSMS-Setup-ENU.exe";
            using(WebClient wc=new WebClient())
            {
                wc.DownloadProgressChanged += Wc_DownloadProgressChanged1;
                wc.DownloadFileAsync(new Uri(url), "ssms.exe");
            }
        }

        private static void Wc_DownloadProgressChanged1(object sender, DownloadProgressChangedEventArgs e)
        {
            Console.WriteLine($"TotalBytesToReceive:{e.TotalBytesToReceive},BytesReceived:{e.BytesReceived},ProgressPercentage:{e.ProgressPercentage}");
        }

 

发表评论

0/200
81 点赞
0 评论
收藏
为你推荐 换一批