首页 > 解决方案 > C# - 无法打开下载的 RAR 或 ZIP 文件

问题描述

需要你的帮助。当我下载自己打开但当我使用 c# windows 下载它时下载成功但未打开,我正在使用此代码下载 Rar 或 Zip 文件。

private void downloadBtn_Click(object sender, EventArgs e) 
{
    WebClient client = new WebClient();
    string tAddress = "Download Link"; // When i Downloaded mySelf it Worked And Opened
    string fileName = "Testfile.Zip";
    Uri uri = new Uri(tAddress);
    client.DownloadFileCompleted += Client_DownloadFileCompleted;
    client.DownloadFileAsync(uri, fileName);

}
private void Client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
    MessageBox.Show("Download Completed Successfully!");
}

这是我尝试打开 Rar 或 Zip 文件时的错误。 它说错误,此文件格式不正确或已损坏,但是当我尝试自己下载时,它已打开

标签: c#

解决方案


该网站不友好也许是故意谁知道但

如果您按照他在这里所做的事情进行操作,它将起作用..

为什么 WebRequest.AllowAutoRedirect 不将初始 url 重定向到正确的下载 url?


推荐阅读