https://github.com/soenneker/soenneker.utils.file.download
Provides a flexible utility for downloading files from specified URIs, with thread-safe concurrency and automatic file name conflict handling
https://github.com/soenneker/soenneker.utils.file.download
csharp dotnet download file filedownloadutil remote util utils
Last synced: 29 days ago
JSON representation
Provides a flexible utility for downloading files from specified URIs, with thread-safe concurrency and automatic file name conflict handling
- Host: GitHub
- URL: https://github.com/soenneker/soenneker.utils.file.download
- Owner: soenneker
- License: mit
- Created: 2024-10-26T00:55:50.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2026-06-05T22:03:37.000Z (about 1 month ago)
- Last Synced: 2026-06-05T22:22:39.041Z (about 1 month ago)
- Topics: csharp, dotnet, download, file, filedownloadutil, remote, util, utils
- Language: C#
- Homepage: https://soenneker.com
- Size: 2.03 MB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- Funding: .github/FUNDING.yml
- License: LICENSE
- Code of conduct: .github/CODE_OF_CONDUCT.md
- Security: .github/SECURITY.md
Awesome Lists containing this project
README
[](https://www.nuget.org/packages/soenneker.utils.file.download/)
[](https://github.com/soenneker/soenneker.utils.file.download/actions/workflows/publish-package.yml)
[](https://www.nuget.org/packages/soenneker.utils.file.download/)
[](https://github.com/soenneker/soenneker.utils.file.download/actions/workflows/codeql.yml)
#  Soenneker.Utils.File.Download
### Provides a flexible utility for downloading files from specified URIs, with thread-safe concurrency and automatic file name conflict handling
## Installation
```
dotnet add package Soenneker.Utils.File.Download
```
## Usage
1. Register `IFileDownloadUtil` within DI (`Program.cs`).
```csharp
public static async Task Main(string[] args)
{
...
builder.Services.AddFileDownloadUtilAsScoped();
}
```
2. Inject `IFileDownloadUtil`
Example:
```csharp
public class TestClass
{
private readonly IFileDownloadUtil _util;
public TestClass(IFileDownloadUtil util)
{
_util = util;
}
public async ValueTask Download()
{
string directory = "path/to/save/files";
List uris = new List
{
"https://example.com/file1.jpg",
"https://example.com/file2.jpg",
"https://example.com/file3.jpg"
};
int maxConcurrentDownloads = 3;
List downloadedFiles = await _util.DownloadFiles(directory, uris, maxConcurrentDownloads);
}
}
```