1

I have to download three .exe files of 7-Zip displaying the download percentage. I created a method according to this article but the "DownloadProgressInProgress" and "DownloadFileComplete" events do not occur.

static void Main(string[] args)
{
    string[] listUri = { "https://www.7-zip.org/a/7z1900.exe", "https://www.7-zip.org/a/7z1900.exe", "https://www.7-zip.org/a/7z1900.exe" };

    for (int a = 0; a < listUri.Length; a++)
    {
        WebClient myWebClient = new WebClient();
        myWebClient.DownloadFileCompleted += new AsyncCompletedEventHandler(DownloadFileComplete);
        myWebClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler(DownloadProgressInProgress);
        myWebClient.DownloadFileAsync(new Uri(listUri[a]), @"C:\\Users\\Luca\\Desktop\\DownloadZip" + (a + 1).ToString() + ".exe");
    }
}

private static void DownloadProgressInProgress(object sender, DownloadProgressChangedEventArgs e)
{
    throw new NotImplementedException();
}

private static void DownloadFileComplete(object sender, AsyncCompletedEventArgs e)
{
    throw new NotImplementedException();
}

How can I do to use the two events by downloading the file list?

Thanks in advance!

Frazzio
  • 17
  • 6
  • What happens when a program gets to the end of the `Main` method? Does it keep executing? Or does it terminate? – mjwills Jun 27 '19 at 13:48
  • Terminate, but if as in this case events are initialized they should happen. Or Not??? :-( – Frazzio Jun 27 '19 at 13:53
  • Thanks! For the suggestions! – Frazzio Jun 27 '19 at 14:01
  • throw new NotImplementedException() = this event is not implemented! The line downloadFileAsync make the download. These events is only for return to the user what is happening. – Tiago NET Oct 03 '22 at 15:23

0 Answers0