gpt4 book ai didi

c# - 使用c#使下载可恢复

转载 作者:太空狗 更新时间:2023-10-29 23:32:00 24 4
gpt4 key购买 nike

我正在使用此方法(WebClient 类)从 Internet 下载文件:

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

如何使用上述代码使下载可恢复

最佳答案

来自 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.

例如:

request.AddRange(1000); 

关于c# - 使用c#使下载可恢复,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17797167/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com