Re: idHttp Works OK in IDE on large download but not in compliled exe
2003-07-02 05:41:32 AM
delphi116
Just found something...it works ok if I don't update the label caption
during download.
"SteveMcG" <smcgrath@no-spam>writes
Quote
Hi Everyone,
I'm using the following code sample to download a large file to local hard
drive. For test purposes I have IIS5.1 running on my local PC. If I run
from
within Delphi 7 IDE, the download runs to completion and I get the 'Download
Complete' dialog. However if I exit Delphi and try to run the compiled
exe,
the progress bar completes but I don't get the final dialog. Also if I try
to delete the target file it shows an access denied (presumable still
locked
by downlad process). A smaller file of about 20MB works Ok. All I have on
form is editbox, antifreeze, progress bar and command button
Any ideas?
procedure TForm1.GetButtonClick(Sender: TObject);
var
F: TFileStream;
begin
//First Display Filesize
idHttp1.Head(Edit1.Text);
Form1.Caption:='FileSize = ' + IntToStr(idHttp1.Response.ContentLength);
//Begin Download
F := TFileStream.Create('c:\download.exe', fmCreate);
try
IdHTTP1.Get(Edit1.Text, F);
finally
F.Free;
end;
end;
procedure TForm1.IdHTTP1WorkBegin(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCountMax: Integer);
begin
if AWorkMode = wmRead then
begin
ProgressBar1.Max := AWorkCountMax;
ProgressBar1.Position := 0;
end;
end;
procedure TForm1.IdHTTP1Work(Sender: TObject; AWorkMode: TWorkMode;
const AWorkCount: Integer);
begin
if AWorkMode = wmRead then
begin
ProgressBar1.Position := AWorkCount;
Label1.Caption := inttostr(100 * AWorkCount div Progressbar1.Max)
+ '% ' + IntToStr(AWorkCount) + ' of ' + IntToStr(Progressbar1.Max) +
'
Bytes';
end;
end;
procedure TForm1.IdHTTP1WorkEnd(Sender: TObject; AWorkMode: TWorkMode);
begin
ShowMessage('Download Complete');
end;