实际上我正在使用 TIdHTTP 组件从 Internet 下载文件。我想知道是否可以使用此组件或另一个 indy 组件暂停和恢复下载。
这是我当前的代码,这适用于下载文件(没有简历),但是 . 现在我想暂停下载关闭我的应用程序,当我的应用程序重新启动时,然后从保存的最后一个位置恢复下载。
var
Http: TIdHTTP;
MS : TMemoryStream;
begin
Result:= True;
Http := TIdHTTP.Create(nil);
MS := TMemoryStream.Create;
try
try
Http.OnWork:= HttpWork;//this event give me the actual progress of the download process
Http.Head(Url);
FSize := Http.Response.ContentLength;
AddLog('Downloading File '+GetURLFilename(Url)+' - '+FormatFloat('#,',FSize)+' Bytes');
Http.Get(Url, MS);
MS.SaveToFile(LocalFile);
except
on E : Exception do
Begin
Result:=False;
AddLog(E.Message);
end;
end;
finally
Http.Free;
MS.Free;
end;
end;