Download a file from the Internet with progress indicator

CK CK 3776 
Created at
Updated at  
551 0 0

If you need to save the contents of a specified URL to a file - and be able to track the download progress, use the TDownLoadURL.

While TDownLoadURL is writing to the specified file, it periodically generates an OnDownloadProgress event, so that you can provide users with feedback about the process.

Here's an example - note that you must include the unit ExtActns in the uses clause. 

uses ExtActns, ...
type
  TfrMain = class(TForm)
  ...
  private
    procedure URL_OnDownloadProgress
       (Sender: TDownLoadURL;
        Progress, ProgressMax: Cardinal;
        StatusCode: TURLDownloadStatus;
        StatusText: String; var Cancel: Boolean) ;
  ...
implementation
...
procedure TfrMain.URL_OnDownloadProgress;
begin
  ProgressBar1.Max:= ProgressMax;
  ProgressBar1.Position:= Progress;
end;
function DoDownload;
begin
  with TDownloadURL.Create(self) do
  try
    URL:='http://z.about.com/6/g/delphi/b/index.xml';
    FileName := 'c:ADPHealines.xml';
    OnDownloadProgress := URL_OnDownloadProgress;
    ExecuteTarget(nil) ;
  finally
    Free;
  end;
end;
{
Note:
URL property points to Internet
FileName is the local file
}
Tags Copy GetModuleHandle Intranet Networking OnDownloadProgress TDownloadURL Facebook X
Comments 0
Similar posts
  1. Are we connected to the Internet?
    419
  2. How to get get IE favorites
    448
  3. How to set the "home page" for the Internet Explorer from Delphi code
    428
  4. List All Network Drives
    389
  5. Retrieving all image links from an HTML document
    416
  6. Exploring the Depths of Data Transfer: sendfile vs. kTLS
    1,314
  7. Dynamic DNS Made Easy: Building a Python-Based Solution
    793
  8. Building a Basic DNS Server in PHP/Python: A Beginner's Guide
    731
  9. Implementing a Versatile DNS Server in Python: Handling A, AAAA, CNAME, and TXT Records
    1,067
  1. Display Standard Windows Properties dialog
    1,125
  2. Disable Mouse and Keyboard from Delphi Code
    787
  3. Detecting Drive Types
    466
  4. Detecting and preventing Windows shut down
    432
  5. Copying Group of Files using Delphi with Standard Animation Dialog (SHFileOperation)
    411
  6. Controling sound volume from code
    417
  7. How to Close Another Application by Windows Caption
    384
  8. How to Change the Windows Start button bitmap
    421
  9. How to capture the output from a DOS (command/console) Window
    960
  10. How to Activate/Deactivate the Screen Saver
    855
  11. Retrieving all image links from an HTML document
    416
  12. List All Network Drives
    389
  13. How to set the "home page" for the Internet Explorer from Delphi code
    428
  14. How to get get IE favorites
    448
  15. Extracting the domain (host) name from an e-mail address
    482
  16. Are we connected to the Internet?
    419
  17. TImage.Bitmap fade out
    369
  18. TDesktopCanvas - draw on Windows Desktop
    548
  19. TColor to HTML color
    410
  20. Show *any* graphics as Glyph on a SpeedButton
    535
  21. Rotating Text
    444
  22. Paint a Form with a tiled bitmap image
    408
  23. Is Point in Polygon?
    367
  24. Implementing a lasso drawing technique
    381
  25. Grayscaling a bitmap ?
    527
  26. Get Cursor Image (draw it on a Canvas)
    681
  27. How to convert HIcon to TIcon ?
    446
  28. Extract an icon from an Windows application and paint on a Form
    412
  29. How to draw transparent text on Windows Desktop
    407
  30. How to draw rotated text
    1,322
Recently updated
  1. How do I create animated background for Google Meet?
    19,000
  2. MaxMind GeoLite2 vs. DB-IP Lite vs. ip-api.com: Choosing the Right Free IP Geolocation Solution
    192
  3. Meet Valkey: Why Redis Changed Its License, Why Valkey is Better, and How to Use It as a Drop-in Replacement
    75
  4. How Rogue Web Scrapers Are Stealing My Content and Destroying My Server
    151
  5. Array of arguments passed to script in PHP
    83
  6. Invalid Auction Storms in Ad Tech
    91
  7. Building MRC-Compliant Instrumentation in Ad Tech: Implementation Steps and Key Challenges
    194
  8. The Two Clocks of Ad Server Architecture
    61
  9. Frequency Cap Architecture Overview
    505
  10. Collecting Proof-of-Play from 100,000 Screens
    139
  11. Vector Search in Relational Databases (RDBs): Trends & Usage Environments
    276
  12. What is RedisVL?
    102
  13. Designing a Skill Registry Architecture: Minimize Token Usage and Maximize AI Performance
    218
  14. TPU & GPU Cluster Management Tools
    229
  15. The Concept of Scaffolding in AI Agents
    217
  16. Beyond Static Pipelines: Architecting LLM Multi-Agent Systems for Autonomous Workflow Orchestration
    568
  17. AI-DLC vs. AI-SDLC: Model-Centric vs. System-Centric AI Development
    246
  18. Fine-Tuning Open-Weight LLMs: Training, Licensing, and Deploying Custom Models with Ollama
    321
  19. Inside the Next-Generation Streaming Architecture: Ultra-Low Latency, SGAI, and AI Codecs
    196
  20. Machine Learning: Training vs. Ranking
    200
  21. The Continuous Learning Machine: Designing a Loop That Actually Turns
    212
  22. The Next-Gen Low-Latency Standards: LL-HLS & MoQ
    188
  23. Designing a Data Curation System Around a Vector Database
    212
  24. Extracting Context from Live Video: The Architecture Got Simpler When We Stopped Building Features
    228
  25. The New Ad Stack Behind Live Sports Streaming: Inside SGAI, EABN, and the Standards Race to Fix Live Monetization
    646
  26. Designing MLOps Architectures to Handle Seasonal Data Drift in EV Fleet Models
    180
  27. From 15 to 40+ FPS: Accelerating PyTorch Object Detection on Automotive ECUs
    203
  28. Understanding Data Lineage
    251
  29. System Requirements and Architecture: Intelligent Priority-Based Scheduler
    159
  30. GPU & LLM Cluster Infrastructure & Task Scheduling Architecture
    229