delphi4arab منتديات دلفي للعرب
Download, pause and resume a download using tnethttpclient1 - نسخة قابلة للطباعة

+- delphi4arab منتديات دلفي للعرب (https://delphi4arab.net/forum)
+-- قسم : منتديات دلفي للعرب التعليمية (https://delphi4arab.net/forum/forumdisplay.php?fid=3)
+--- قسم : سؤال و جواب حول دلفي (https://delphi4arab.net/forum/forumdisplay.php?fid=15)
+--- الموضوع : Download, pause and resume a download using tnethttpclient1 (/showthread.php?tid=11358)



Download, pause and resume a download using tnethttpclient1 - invocker - 14-05-2021

السلام عليكم


احتاج مثال لعمل Download, pause and resume a download using tnethttpclient1

يكون بسيط ومفهوم مع شرح الكود

بارك الله فيكم


RE: Download, pause and resume a download using tnethttpclient1 - محمد عبد العزيز - 14-05-2021

وعليكم السلام
حاول الكتابة باللغة العربية

ضمن RAD Studio Demo Code تجد مثال
HttpDownloadManager

https://sourceforge.net/p/radstudiodemos


RE: Download, pause and resume a download using tnethttpclient1 - invocker - 14-05-2021

بارك الله فيك اطلعت عليه سابقا لكن كنت اريد كود اكثر وضوحا وجدت كود بسيط يعتمد على Tidhttp قمت بتحويله لكن توقفت عند هذا السطر لم اعرف مقابله في tnethttpclient

idhttp.Request.Range := IntToStr(f.Position) + '-'+  IntToStr(aRangeEnd);

كود :
procedure Download(Url,LocalFile:String;   WorkBegin:TWorkBeginEvent;Work:TWorkEvent;WorkEnd:TWorkEndEvent); var   Http: TIdHTTP;   exit:Boolean;   FLength,aRangeEnd:Integer; begin   Http  := TIdHTTP.Create(nil);   fFileStream:=nil;   try     try       Http.OnWork:= Work;       Http.OnWorkEnd := WorkEnd;       Http.Head(Url);       FLength := Http.Response.ContentLength;       exit:=false;       repeat         if not FileExists(LocalFile) then begin           fFileStream := TFileStream.Create(LocalFile, fmCreate);         end         else begin           fFileStream := TFileStream.Create(LocalFile, fmOpenReadWrite);           exit:= fFileStream.Size >= FLength;           if not exit then             fFileStream.Seek(Max(0, fFileStream.Size-4096), soFromBeginning);         end;         try           aRangeEnd:=fFileStream.Size + 50000;           if aRangeEnd < fLength then begin                      Http.Request.Range := IntToStr(fFileStream.Position) + '-'+  IntToStr(aRangeEnd);           end           else begin             Http.Request.Range := IntToStr(fFileStream.Position) + '-';             exit:=true;           end;           Http.Get(Url, fFileStream);         finally           fFileStream.Free;         end;     until exit;     Http.Disconnect;     except       on E : Exception do       Begin       //Result:=False;       //AddLog(E.Message);       end;     end;   finally     Http.Free;   end; end;