Mega Code Archive

 
Categories / Delphi / Files
 

Downloading Files

Title: Downloading Files Question: How do i download a file (with code) Answer: Seems as if not too many people know about the great URLMon (included with delphi)... Heres a quick example that will download index.html from www.scrapcode.com, to c:\ : unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, URLMon; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin URLDownloadToFile(nil, 'http://www.scrapcode.com/index.html', 'c:\index.html', 0, nil); end; end.