WebClient,DownloadFileAsync,DownloadProgressChanged

  • A+
所属分类:.NET技术
摘要

 

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

WebClient,DownloadFileAsync,DownloadProgressChanged