Fast, cross-platform and reliable multipart downloader with asynchronous progress events for .NET applications.
Fast, cross-platform and reliable multipart downloader with asynchronous progress events for .NET applications.
:rocket: Fast, cross-platform, and reliable multipart downloader in .Net :rocket:
[!TIP] Prefer a ready-to-use app over a library? Meet Downloader Desktop — a free, open-source GUI download manager for Windows · Linux · macOS, powered by this engine: multi-connection downloads, pause/resume, queues, scheduler, speed limits and more — with no dependencies to install.
Downloader is a modern, fluent, asynchronous, and portable library for .NET, built with testability in mind. It supports multipart downloads with real-time asynchronous progress events. The current v5.x line targets .NET 8, .NET 9, and .NET 10. (If you need .NET Standard 2.1 or older runtimes such as .NET Framework 4.6.1, use the v3.x line — see the note below.)
Downloader works on Windows, Linux, and macOS.
Note: Support for older versions of .NET was removed in Downloader
v3.2.0. From this version onwards, only.Net 8.0and higher versions are supported.
If you need compatibility with older .NET versions (e.g.,.NET Framework 4.6.1), use Downloaderv3.1.*.
For a complete example, see the Downloader.Sample project in this repository.
dotnet add package Downloaderawait DownloadBuilder
.New()
.WithUrl(@"https://host.com/test-file.zip")
.WithDirectory(@"C:\temp")
.Build()
.StartAsync();ChunkCount to control download segmentation..download), then renames to the final name on completion.DownloadPackage object..download file — no extra files or manual serialization needed.RemoteFileResolver).HttpClient or HttpMessageHandler injection for advanced scenarios (e.g., IHttpClientFactory, HTTP caching, custom delegating handlers).PM> Install-Package Downloaderdotnet add package Downloadervar downloadOpt = new DownloadConfiguration()
{
// Number of file parts, default is 1
ChunkCount = 8,
// Download parts in parallel (default is false)
ParallelDownload = true
};Note: Only include the options you need in your application.
…A good general-purpose starting point — parallel for speed, with retries and auto-resume for safety:
…Tip: Higher
ChunkCount/ParallelCountis not always faster — many servers rate-limit or cap connections per client. Values around8chunks and4parallel connections are a safe, fast default; tune for your target hosts.
var downloader = new DownloadService(downloadOpt);…Example handler implementations:
…⚠️ Important: how failures and cancellations are reported
DownloadFileTaskAsync(...)/StartAsync(...)do not throw when a download fails or is cancelled. The awaited call completes normally, and the outcome is delivered through theDownloadFileCompletedevent:
- Success →
e.Cancelled == falseande.Error == null- Failure →
e.Errorcontains the exception (e.g. a network error, or anIncompleteDownloadExceptionif the server ended the stream early)- Stopped/paused by you →
e.Cancelled == trueAlways subscribe to
DownloadFileCompletedand checke.Errorbefore treating the file as complete — relying only on theawaitreturning will silently miss failed downloads. You can also inspectdownloader.Package.Status(Completed/Stopped/Failed).
string file = @"Your_Path\fileName.zip";
string url = @"https://file-examples.com/fileName.zip";
await downloader.DownloadFileTaskAsync(url, file);DirectoryInfo path = new DirectoryInfo("Your_Path");
string url = @"https://file-examples.com/fileName.zip";
// download into "Your_Path\fileName.zip"
await downloader.DownloadFileTaskAsync(url, path); // After the download completes, you get a MemoryStream
Stream destinationStream = await downloader.DownloadFileTaskAsync(url); Sometimes you need a remote file's name and size before (or without ever) downloading it — for example to populate a list/grid of queued downloads with their names and sizes while they wait for a slot, instead of starting and immediately stopping a real download just to read the headers.
Use RemoteFileResolver. It performs a single lightweight header probe (a Range: 0-0 GET that
follows redirects) and resolves the file name exactly the way the downloader does internally — from
the Content-Disposition header, falling back to the URL path, and finally to a generated GUID —
plus the size (Content-Range → Content-Length) and whether the server supports ranged
(resumable) downloads.
// Just the file name
// (resilient: falls back to the URL-derived name
// on a network/server error)
string fileName = await RemoteFileResolver.GetFileNameAsync(url);
// Full metadata in one probe:
RemoteFileInfo info = await RemoteFileResolver.GetFileInfoAsync(url);
Console.WriteLine($"{info.FileName} — {info.FileSize} bytes, range: {info.SupportsRange}");
// info.Address is the final URL after any redirects.Both methods accept an optional DownloadConfiguration (to reuse your headers, proxy, credentials,
cookies, redirect policy, …) and a CancellationToken. Each call owns and disposes its own client,
so when resolving many URLs at once add your own concurrency limiting / timeouts.
If you already hold a download service, the same lookup is available on it (using that service's configuration, without disturbing any download in progress):
RemoteFileInfo info = await downloader.GetFileInfoAsync(url);Note:
FileSizeis-1when the server does not advertise a length.GetFileNameAsyncand the service/GetFileInfoAsyncpreviews are best-effort and won't throw on a server that hides its size — you still get a usable name.
When you want to resume a download quickly after pausing for a few seconds, call the Pause function of the downloader service. This way, the streams stay alive and are only suspended by a lock, to be released and resumed whenever you want.
// Pause the download
downloader.Pause();
// Resume the download
downloader.Resume();The DownloadService class has a property called Package that holds a live snapshot of the download state (chunk positions, URL, file path, etc.). While the download is in progress, this object is updated continuously.
To stop and later resume a download manually, you are responsible for keeping the Package object yourself — either in memory or serialized to disk. The Downloader does not store it for you in this approach.
// 1. Keep a reference to the package before or after stopping:
DownloadPackage pack = downloader.Package;Stop or cancel the download:
// Fire-and-forget cancellation (returns void):
downloader.CancelAsync();
// Or await until the download has actually stopped before reading the package:
await downloader.CancelTaskAsync();Resume later — even after restarting the application:
// Pass the same (or deserialized) package to resume from the last position:
await downloader.DownloadFileTaskAsync(pack);The Package object is lightweight — it contains only the URL, file path, and the position of each chunk (not the downloaded bytes). You can serialize it to JSON or binary (see Serialization section) and restore it at any time.
For more details see the StopResumeDownloadTest method.
Note: If the server does not support HTTP range requests, the download cannot be resumed and will restart from the beginning.
If you don'
No open issues yet, or sync has not completed.