首页 新闻 会员 周边

C# 使用WebClient类的DownloadFileAsync()方法下载zip失败问题

0
悬赏园豆:20 [已关闭问题] 关闭于 2021-10-13 18:24

/// <summary>
/// 下载更新
/// </summary>
public void Update()
{
try
{
if (!isUpdate)
return;
WebClient wc = new WebClient();
string filename = "Update_NewVersion.zip";
filename = Path.GetDirectoryName(loadFile) + "\" + filename;//保存地址

            FinalZipName = filename;//下载地址
           
            wc.DownloadFileAsync(new Uri(download), filename);
            wc.DownloadProgressChanged += new DownloadProgressChangedEventHandler(wc_DownloadProgressChanged);
            wc.DownloadFileCompleted += new System.ComponentModel.AsyncCompletedEventHandler(wc_DownloadFileCompleted);
            wc.Dispose();
        }
        catch(Exception ex)
        {
            throw new Exception("更新出现错误,网络连接失败);
        }
    }

代码执行可以成功,但是没有下载到zip文件,问题找了好久没找到原因,麻烦大神帮我看看问题出在哪里,我的下载地址放的是阿里云的oss zip文件地址。

< >
分享
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册