Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

make download resumable using c#

I am using this method (WebClient Class) for downloading a file from the Internet :

private Task DownloadUpdate(string url, string fileName)
{
       var wc = new WebClient();
       return wc.DownloadFileTaskAsync(new Uri(url), @"c:\download" + fileName);
}

How can I make the download resumable using the above code?

like image 945
Sirwan Afifi Avatar asked Jul 22 '13 20:07

Sirwan Afifi


1 Answers

From HttpWebRequest or WebRequest - Resume Download ASP.NET:

Resuming files is done by specifying the byte range of the file you would like to download using the Range HTTP header. This can be done in .NET with the HttpWebRequest.AddRange function.

For example:

request.AddRange(1000); 
like image 110
Sirwan Afifi Avatar answered Sep 27 '22 21:09

Sirwan Afifi