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}"); }

轉載請註明出處,本文鏈接:https://www.uj5u.com/net/3503.html
標籤:C#
下一篇:創建型設計模式總結
