cheran
cheran

Reputation: 483

Webclient Resume download with Async

I am implementing multiple file download progress in my WPF application. I need to maintain the downloaded data and resume the download if the internet fails during download.

For example, during the download progress if the internet fails i need to wait for 5 mins for the internet to reconnect and resume the download, if it fails to reconnect after 5 mins then the request needs to be terminated. And also the process needs to be Async since i am downloading multiple files and the second file must not start downloading second before the first file is downloaded.

     using (client = new WebClient())
                    {
                        try
                        {   
                            client.DownloadProgressChanged += client_DownloadProgressChanged;
                            client.DownloadFileCompleted += client_DownloadFileCompleted(fileName);
                            await AsyncPlatformExtensions.DownloadFileTaskAsync(client, new Uri(sourceUri), outputDir);
                        }
                        catch(WebException  exe)
                        {

                        }
                        catch(Exception e)
                        {

                        }
                    }

I have checked a few links like below but none seems to be working.

https://github.com/Avira/.NetFileDownloader

https://github.com/markodt/SGet

https://www.codeproject.com/Tips/307548/Resume-Suppoert-Downloading

Please share your thoughts on how to retain the download cache and resume the download if the internet reconnects within a specified time.

Regards,

Cheran

Upvotes: 6

Views: 349

Answers (0)

Related Questions