Reputation: 7
The Following Code Downloads a ZIP Archive when the Button inside the Application is Pressed. The File seems to be there but when I try to open it or extract it, I get the following error message: 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.");
}
Upvotes: 0
Views: 2564
Reputation:
The URL you have embedded in your code does not actually correspond to a ZIP file. When I try loading it, I get an HTML page prompting me to download a file.
You will, in all probability, need to host the file somewhere else. 4Shared is almost certainly not interested in allowing their service to be used for blind downloads like this. (They make a lot of their revenue off the ads on the download page, after all.)
Upvotes: 2