delphi IdHTTP控件断点下载


本文整理自网络,侵删。

 uses IdHTTP;

//下载主函数
procedure HttpDownLoad(aURL, aFile: string; bResume: Boolean);
var
IdHTTP: TidHttp;
tStream: TFileStream;
begin //Http方式下载
IdHTTP:= Tidhttp.Create(nil);
if FileExists(aFile) then //如果文件已经存在
tStream := TFileStream.Create(aFile, fmOpenWrite) else
tStream := TFileStream.Create(aFile, fmCreate);

if bResume then //续传方式
begin
IdHTTP.Request.ContentRangeStart := tStream.Size - 1;
tStream.Position := tStream.Size - 1; //移动到最后继续下载
IdHTTP.Head(aURL);
IdHTTP.Request.ContentRangeEnd := IdHTTP.Response.ContentLength;
end else //覆盖或新建方式
begin
IdHTTP.Request.ContentRangeStart := 0;
end;

try
IdHTTP.Get(aURL, tStream); //开始下载
finally
tStream.Free;
end;
end;

相关阅读 >>

Delphi socket connect timeout 套字节链接超时设置

Delphi 动态库里查询是否联接数据库

Delphi 网上获取北京时间idhttpserver and idhttp 使用 encoding utf8

Delphi压缩与解压_不需要特别的控件

Delphi 在windows平台下实现进程隐藏

Delphi ntfs usn 磁盘文件搜索

Delphi中的record怎么动态分配内存?

Delphi版雪花算法

dekphi 智能《疯狂刷新》辅助工具v3.1更新开源

Delphi xe6 实现ping的功能

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...