WebClient.DownloadFileAsync[
^] does not block the calling thread. Your method returns before the download has finished. It's likely that the
WebClient
instance will be destroyed when the method returns, so the download will be aborted.
Either use
the DownloadFile
method[
^], which
does block the calling thread; or make your method
async
and use
the DownloadFileTaskAsync
method[
^]:
public static async Task DownloadFile()
{
using WebClient client = new WebClient();
Uri uri = new Uri("...");
client.DownloadProgressChanged += DownloadProgress;
await client.DownloadFileTaskAsync(uri, "test.apk");
}