Thread: Download a file

    #1
  1. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Dec 2003
    Posts
    52
    Rep Power
    11

    Download a file


    Is there a simple control or function that can allow me to download a file from a webserver and save it locally? I need to cache some files for my program for later use from a web server. Thanks
  2. #2
  3. Banned ;)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Nov 2001
    Location
    Woodland Hills, Los Angeles County, California, USA
    Posts
    9,625
    Rep Power
    4247
    Use URLDownloadToFile.

    Code:
    uses
       urlmon;
    ...
    ...
    begin
       URLDownloadToFile(nil, PChar(url_to_download), PChar(filename_to_save), 0, nil);
    end;
    Note that url_to_download should include 'http://' in the beginning. If you use 'www.yahoo.com/' instead of 'http://www.yahoo.com/', it won't work because the http:// is missing.
    Up the Irons
    What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
    "Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
    Down with Sharon Osbourne

    "I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo

IMN logo majestic logo threadwatch logo seochat tools logo