Registriert seit: 17. Feb 2007
Ort: NRW
420 Beiträge
Delphi 2010 Professional
|
AW: Http
26. Feb 2016, 19:23
Delphi-Quellcode:
uses
// Indy
IdHTTP,
// OmniThreadLibrary
OtlParallel, OtlTaskControl,
procedure DownloadFile( const AURL, AFileName: string);
var
LIdHTTP: TIdHTTP;
LFileStream: TFileStream;
begin
LIdHTTP := TIdHTTP.Create( nil);
try
LFileStream := TFileStream.Create(AFileName, fmCreate);
try
LFileStream.Position := 0;
LIdHTTP.Get(AURL, LFileStream);
finally
LFileStream.Free;
end;
finally
LIdHTTP.Free;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
Async(
{ . } procedure
{ . } begin
{ ... } DownloadFile(' http://example.com/my.csv', ' C:\my.csv');
{ . } end). { . }
Await(
{ . } procedure
{ . } begin
{ ... } ShowMessage(' Hurra! Datei heruntergeladen :)');
{ . } end);
end;
Mehr ist das nicht
Sebastian
|
|
Zitat
|