DelphiFAQ Home Search:
General :: Programming :: Delphi :: Network
Network (local network and Internet) programming under Windows with Delphi.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Download a file from the web (internet)

Question:

Is there an easy function to download a file via http protocol?

Answer:

Yes, there is. It's called UrlDownloadToFile() and it's defined in unit URLMon. The code below shows how to use it.

uses 
   URLMon; 
 
 //-------------------------------------------------------------
// SourceFile = http address e.g. http://www.ibm.com/test.gif
// DestFile = filename where to save the file
//
function DownloadFile(SourceFile, DestFile: string): Boolean; 
 begin 
   try 
     Result := UrlDownloadToFile(nil, PChar(SourceFile), PChar(DestFile), 0, nil) = 0; 
   except 
     Result := False; 
   end; 
 end; 
 
You don't like the formatting? Check out SourceCoder then!
Generated 4:01:12 on Aug 21, 2018