DelphiSoure.comDelphiSoure.com
  Welcome Guest [Login] [Register] [Add/Edit/Delete Resources] [Link Us!] 39 Users Online, September 9, 2010 



Main Menu
   Top 50 Downloads
   Components
   News
   Online Forum
   Tips and Hints
   News Archive
   Gazette Archive
   Links
   Delphi Books
   Advertising
   About DelphiSource

 
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

Advertise Here!

Video component for Delphi/C++Builder
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...
[Visit Sponsor]

CoolDev.Com - Award winning Delphi components, CD/DVD toolkits, consulting and offshore development services.
[Visit Sponsor]

Datastead - VCL components for web and multimedia applications.
[Visit Sponsor]


Search DelphiSource.com
  

 
 Top 10 Downloads
 • [12447] ExDBGrid Component Suite
 • [12373] abfLabels
 • [9932] Storage library v2.72
 • [9841] Data Navigator
 • [8999] Audio Tools Library 1.3
 • [6951] Monster FTP
 • [6690] Peer to Peer Component Suite
 • [6370] TIAgaloLED
 • [6366] TAudioMixer
 • [5296] abfComControls

 Featured Book

More Books...
© Copyright DelphiSource 1998 - 2002
Contact Us: delphisource@delphisource.com