Main Menu
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
|
•
|
 |
|
|
| Topic: Downloading files using HTTP |
| Name: bee |
| Body: |
Hi, I'm using IdHTTP components to make a connection and download the files from server. What is the properties and events thst i should use if i want download a files using HTTP and get that files's size? Please give an advices. here is the part of codes i already wrote: // function TfrmMain.DownloadFile(FastServer, NewFileList: String): Boolean; var http: TIdHttp; VersionList: TStrings; i: Integer; FileSize: Integer; TotalSize: Integer; begin http := TIdHttp.Create(nil); try http.Host := RetrieveCSV(FastServer, sfFieldHost); http.Connect; if http.Request.BasicAuthentication = True then begin http.Request.Username := RetrieveCSV(FastServer, sfFieldUsername); http.Request.Password := RetrieveCSV(FastServer, sfFieldPassword); end; http.Connect; VersionList.LoadFromFile(GetWindowsTempDir + VerFile); begin for i := 0 to VersionList.Count - 1 do begin if not FileExists(RetrieveCSV(VersionList[i],1)) then //FileSize := get the files's size //Download the files ('RetrieveCSV(VersionList[i],1), GetWindowsTempDir + RetrieveCSV(VersionList[i],1)'); Result := True; TotalSize:= (TotalSize + FileSize); end; |
| Topic: RE: Downloading files using HTTP |
| Name: semicolon |
| Body: |
I use "OnWorkBegin" event to get "AWorkCountMax" parameter. for example:-
procedure TfrmSSCMain.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode; const AWorkCountMax: Integer); begin IdHTTP1.Tag := AWorkCountMax; lblDownloadProgress.Caption := Format('Download 0%% (0 of %d)', [IdHTTP1.Tag]); Application.ProcessMessages; end;
procedure TfrmSSCMain.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode; const AWorkCount: Integer); begin lblDownloadProgress.Caption := Format('Download %.2f%% (%d of %d)', [AWorkCount / IdHTTP1.Tag * 100, AWorkCount, IdHTTP1.Tag]); Application.ProcessMessages; end;
procedure TfrmSSCMain.IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode); begin lblDownloadProgress.Caption := 'Download completed!'; Application.ProcessMessages; end;
|
Reply to this Topic
 Sponsored Links |
|
|
|
AVI and ASF recording, compression on-the-fly or after recording, live network streaming, media player, DV timecode, DV date/time, DV camcorder control, motion detection, frame capture, frame overlay, TV tuning, videos built from set of images, deinterlacing, video rotation, brightness/contrast, dual display, and more...
|
|
|
-
Award winning Delphi components, CD/DVD toolkits, consulting and offshore development services.
|
|
|
-
VCL components for web and multimedia applications.
|
|
 |
 Search DelphiSource.com |
|
 |
|
|
 Top 10 Downloads |
| • [12447] | | • [12373] | | • [9932] | | • [9841] | | • [8999] | | • [6951] | | • [6690] | | • [6370] | | • [6366] | | • [5296] |
 |
|