作为一个不熟悉基本原理,又想偷懒的妹子,写代码好像真心有点耗时。

原本,winfrom下载并显示进度条的方法,已经很泛滥。可是看不懂。要理解基础真心很难。

so。翻山遍野终于找到了了这个方法。看起来简单些。

 

      winfrom 使用DownloadFileAsync下载并显示进度条 

 

 

代码如下:

 

 private void 进度条提示_Load(object sender, EventArgs e)
        {
            try
            {
WebClient wed = new WebClient();//初始化新实例 wed.DownloadProgressChanged += DownloadProgressChanged; wed.DownloadFileAsync(new Uri(下载地址), 保存地址); //保存地址 异步 } catch (System.Exception c) { MessageBox.Show(c.Message, "消息提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } } public void DownloadProgressChanged(object sender, DownloadProgressChangedEventArgs e) { Action<DownloadProgressChangedEventArgs> on = PeceChange; on.Invoke(e); } protected void PeceChange(DownloadProgressChangedEventArgs e) { progressBar1.Value = e.ProgressPercentage; label1.Text = e.ProgressPercentage.ToString() + "%"; }

 

  

 

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-10-27
  • 2021-09-08
  • 2022-02-04
猜你喜欢
  • 2022-12-23
  • 2021-11-26
  • 2021-06-11
  • 2022-01-01
  • 2022-12-23
  • 2021-11-18
相关资源
相似解决方案