Mirror

Download file from internet (Views: 100)


Problem/Question/Abstract:

How to download file from internet?

Answer:

uses UrlMon;

function DownloadFile(Source, Dest: string): Boolean;
begin
  try
    Result := UrlDownloadToFile(nil, PChar(source), PChar(Dest), 0, nil) = 0;
  except
    Result := False;
  end;
end;

//Example:

procedure TForm1.Button1Click(Sender: TObject);
begin
  if DownloadFile('http://dkb.kastu.lt/index.html', 'c:\index.html') then
    ShowMessage('Download succesful')
  else
    ShowMessage('Download unsuccesful');
end;

<< Back to main page