使用C#使下载断点续传 [英] make download resumable using c#

查看:215
本文介绍了使用C#使下载断点续传的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用这个方法( Web客户端班)从互联网上下载一个文件:

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

如何让下载的可恢复的使用上面的code?

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

推荐答案

从<一个href=\"http://stackoverflow.com/questions/1336203/httpwebrequest-or-webrequest-resume-download-asp-net\">HttpWebRequest或WebRequest的 - 简历下载ASP.NET :

恢复文件是通过指定该文件的字节范围做你
  想使用Range HTTP标头进行下载。这是可以做到
  与 HttpWebRequest.AddRange 功能。

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.

例如:

request.AddRange(1000); 

这篇关于使用C#使下载断点续传的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆