VB.NET DownloadFileAsync触发完成事件,但不下载 [英] VB.NET DownloadFileAsync fires completion event but doesn't download

查看:591
本文介绍了VB.NET DownloadFileAsync触发完成事件,但不下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想下载一个.zip文件进行自动更新我的比赛。它需要显示进度。我跟着一个在线教程,并得到了code的这个块的实际下载:

I'm trying to download a .zip file to make an auto-updater for my game. It needs to show progress. I followed an online tutorial and got this chunk of code for the actual downloader:

    Dim SaveDirectory As String = "C:\Program Files (x86)\MyGame\"
    Dim client As WebClient = New WebClient
    AddHandler client.DownloadProgressChanged, AddressOf client_ProgressChanged
    AddHandler client.DownloadFileCompleted, AddressOf client_DownloadCompleted
    client.DownloadFileAsync(New Uri("https://example.com/game/download/latest.zip"), SaveDirectory)

我现在的问题是,当我运行Windows窗体应用程序中,DownloadFileCompleted触发事件,然而,这个文件的下载出于某种原因。

这是关于一个34 MB的.zip文件。任何帮助AP preciated,许多感谢。

It's about a 34 MB .zip file. Any help appreciated, and many thanks.

推荐答案

DownloadFileCompleted 被激发,做检查了几件事。

When DownloadFileCompleted is fired, do check a few thing.

有关下载成功


  • e.Cancelled 一定是假的。

  • e.Error 为空

  • e.Cancelled must be false.
  • e.Error should be null

如果 e.Error ,然后将其持有的异常对象,描述的细节是什么出了错与异步操作

if e.Error is not null, then it hold the Exception object, that describes the detail of what went wrong with the Async Operation

这篇关于VB.NET DownloadFileAsync触发完成事件,但不下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆