1

我正在尝试下载 .zip 文件来为我的游戏制作自动更新程序。它需要显示进步。我按照在线教程获得了实际下载器的这段代码:

    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 文件。任何帮助表示赞赏,非常感谢。

4

1 回答 1

1

DownloadFileCompleted被解雇时,请检查一些事情。

成功下载

  • e.Cancelled一定是假的。
  • e.Error应该为空

如果e.Error不是null,则它包含 Exception 对象,该对象描述了错误的详细信息Async Operation

于 2013-03-17T07:43:56.897 回答