0

当按下应用程序内的按钮时,以下代码会下载 ZIP 存档。该文件似乎在那里,但是当我尝试打开它或提取它时,我收到以下错误消息:Archive Unknown Format or Damaged.

private void Button_Click_1(object sender, RoutedEventArgs e)
    {
        string url = @"http://dc659.4shared.com/download/eRPYQvPM/Medieval_Silver_for_PC.zip?tsid=20130403-023918-42de479a";
// Create an instance of WebClient
System.Net.WebClient client = new System.Net.WebClient();
// Hookup DownloadFileCompleted Event
client.DownloadFileCompleted +=    new AsyncCompletedEventHandler(client_DownloadFileCompleted);

// Start the download and copy the file to c:\temp
client.DownloadFileAsync(new Uri(url), 
@"Extract.zip");
 }

void client_DownloadFileCompleted(object sender, AsyncCompletedEventArgs e)
{
    MessageBox.Show("Thank you for downloading! To play extract the ZIP folder.");
}
4

1 回答 1

2

您在代码中嵌入的 URL 实际上并不对应于 ZIP 文件。当我尝试加载它时,我得到一个 HTML 页面,提示我下载文件。

您很可能需要将文件托管在其他地方。4Shared 几乎肯定对允许他们的服务用于这样的盲目下载不感兴趣。(毕竟,他们从下载页面上的广告中赚取了很多收入。)

于 2013-04-03T03:01:24.270 回答