Search code examples
c#downloadasync-awaitwebclientdownloadfileasync

How to download an .exe file successfully in C#?


I am trying to download a test.exe file with this code:

public void DownloadFile()
{
    using(var client = new WebClient())
    {
         client.DownloadFileAsync(new Uri("http://www.acromix.net16.net/download/test.exe"), "test.exe");
    }
}

With this simple code, I debug it and this was the output: output

I don't know and have no idea why it is 0 KB (should be 328 KB). [/downloads]

How can I make it work?

EDIT: The hosting site (000webhost) blocks .exe files to download...


Solution

  • Thanks for the answers...

    Anyway, I found out that I can't really download an .exe file from where I hosted my website (000webhost) because it is blocked (for safety reasons I think).

    A workaround, first, I need to put an .exe file to a zip folder then upload it so I would be able to download it successfully...