I have this C# code but the final esi.zip results in 0 length or basically empty. The URL does exist and confirms to download the file manually. I am baffled buy this.
string zipPath = @"C:\download\esi.zip";
Client.DownloadFileAsync(new Uri("http://ec.europa.eu/economy_finance/db_indicators
/surveys/documents/series/nace2_ecfin_1409/all_surveys_total_sa_nace2.zip"), zipPath)
Thanks
UPDATED: I updated the code where no spaces exist at all but it still downloads 0 bytes.
Here's the working code. There were 2 things you were not doing, that was causing the
0
byte file to be downloaded.IsBusy
. That needs to be called in order for the code to wait for the current thread to complete, since the an async action will be on a new thread.Create a blank console app and put the following code in it and try it out.
Paste this code into Program.cs file of the blank/new console app.
Add a new C# class file called DownloadManager and drop this code in it.
Now Build and run the console app. You should see the progress in the console output window like so.
And when it's complete, you should see the zip file in the location specified in the
targetdownloadedFile
variable, which in this example is atC:\Temp\TestZip.zip
on your local machine.