make download resumable using c#

狂风中的少年 提交于 2019-12-10 06:41:06

问题


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?


回答1:


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); 


来源:https://stackoverflow.com/questions/17797167/make-download-resumable-using-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!