Ecng.Backup 1.0.263

dotnet add package Ecng.Backup --version 1.0.263
                    
NuGet\Install-Package Ecng.Backup -Version 1.0.263
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Ecng.Backup" Version="1.0.263" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Ecng.Backup" Version="1.0.263" />
                    
Directory.Packages.props
<PackageReference Include="Ecng.Backup" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Ecng.Backup --version 1.0.263
                    
#r "nuget: Ecng.Backup, 1.0.263"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Ecng.Backup@1.0.263
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Ecng.Backup&version=1.0.263
                    
Install as a Cake Addin
#tool nuget:?package=Ecng.Backup&version=1.0.263
                    
Install as a Cake Tool

Ecng.Backup

Core abstractions for cloud backup services. This library defines the unified interface IBackupService that all backup providers implement.

Overview

The library provides a provider-agnostic API for working with cloud storage services. You can upload, download, delete, and publish files using the same code regardless of whether you're using AWS S3, Azure Blob Storage, Yandex.Disk, or Mega.

Key Types

BackupEntry

Represents a file or folder in cloud storage.

var folder = new BackupEntry { Name = "my-folder" };
var file = new BackupEntry
{
    Name = "data.zip",
    Parent = folder  // Creates path: my-folder/data.zip
};

// Get full path including all parents
string path = file.GetFullPath(); // "my-folder/data.zip"

// Access metadata (populated after FillInfoAsync or FindAsync)
long size = file.Size;
DateTime modified = file.LastModified;

IBackupService

The main interface for interacting with cloud storage.

public interface IBackupService : IDisposable
{
    // Feature detection
    bool CanPublish { get; }        // Supports public URLs
    bool CanExpirable { get; }      // Supports expiring public URLs
    bool CanFolders { get; }        // Supports folder creation
    bool CanPartialDownload { get; } // Supports range downloads

    // Operations
    Task CreateFolder(BackupEntry entry, CancellationToken ct = default);
    IAsyncEnumerable<BackupEntry> FindAsync(BackupEntry parent, string criteria);
    Task FillInfoAsync(BackupEntry entry, CancellationToken ct = default);
    Task DeleteAsync(BackupEntry entry, CancellationToken ct = default);
    Task DownloadAsync(BackupEntry entry, Stream stream, long? offset, long? length,
                       Action<int> progress, CancellationToken ct = default);
    Task UploadAsync(BackupEntry entry, Stream stream,
                     Action<int> progress, CancellationToken ct = default);
    Task<string> PublishAsync(BackupEntry entry, TimeSpan? expiresIn = null,
                              CancellationToken ct = default);
    Task UnPublishAsync(BackupEntry entry, CancellationToken ct = default);
}

Usage Examples

Uploading a File

// Works with any IBackupService implementation
async Task UploadFileAsync(IBackupService service, string localPath, string remotePath)
{
    var entry = new BackupEntry { Name = remotePath };

    await using var stream = File.OpenRead(localPath);
    await service.UploadAsync(entry, stream, progress =>
    {
        Console.WriteLine($"Upload progress: {progress}%");
    });
}

Downloading a File

async Task DownloadFileAsync(IBackupService service, string remotePath, string localPath)
{
    var entry = new BackupEntry { Name = remotePath };

    await using var stream = File.Create(localPath);
    await service.DownloadAsync(entry, stream, null, null, progress =>
    {
        Console.WriteLine($"Download progress: {progress}%");
    });
}

Partial Download (Resume Support)

async Task ResumeDownloadAsync(IBackupService service, BackupEntry entry, string localPath)
{
    if (!service.CanPartialDownload)
        throw new NotSupportedException("Service doesn't support partial downloads");

    var fileInfo = new FileInfo(localPath);
    long existingBytes = fileInfo.Exists ? fileInfo.Length : 0;

    // Get total file size
    await service.FillInfoAsync(entry);
    long remaining = entry.Size - existingBytes;

    if (remaining <= 0)
        return; // Already complete

    await using var stream = new FileStream(localPath, FileMode.Append);
    await service.DownloadAsync(entry, stream, existingBytes, remaining,
        progress => Console.WriteLine($"Resume progress: {progress}%"));
}

Listing Files

async Task ListFilesAsync(IBackupService service, string folderPath)
{
    var folder = new BackupEntry { Name = folderPath };

    await foreach (var entry in service.FindAsync(folder, criteria: "*.zip"))
    {
        Console.WriteLine($"{entry.GetFullPath()} - {entry.Size} bytes");
    }
}

Publishing a File

async Task<string> ShareFileAsync(IBackupService service, BackupEntry entry)
{
    if (!service.CanPublish)
        throw new NotSupportedException("Service doesn't support publishing");

    // Permanent public URL (if supported)
    string permanentUrl = await service.PublishAsync(entry);

    // Or expiring URL (7 days max for S3)
    if (service.CanExpirable)
    {
        string tempUrl = await service.PublishAsync(entry, TimeSpan.FromHours(24));
    }

    return permanentUrl;
}

Working with Folders

async Task OrganizeFilesAsync(IBackupService service)
{
    if (!service.CanFolders)
    {
        // S3-like services use virtual folders via path prefixes
        var file = new BackupEntry { Name = "backups/2024/january/data.zip" };
        // The "folders" are created implicitly
        return;
    }

    // Services like Yandex.Disk require explicit folder creation
    var folder = new BackupEntry { Name = "backups" };
    await service.CreateFolder(folder);

    var subfolder = new BackupEntry { Name = "2024", Parent = folder };
    await service.CreateFolder(subfolder);
}

Available Implementations

Package Service CanPublish CanFolders CanPartialDownload
Ecng.Backup.AWS Amazon S3 Yes No Yes
Ecng.Backup.AWS Amazon Glacier No No No
Ecng.Backup.Azure Azure Blob Storage Yes No Yes
Ecng.Backup.Yandex Yandex.Disk Yes Yes Yes
Ecng.Backup.Mega Mega.nz Yes Yes No

NuGet

Install-Package Ecng.Backup
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 is compatible.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (7)

Showing the top 5 NuGet packages that depend on Ecng.Backup:

Package Downloads
StockSharp.Xaml

Misc graphical components. More info on web site https://stocksharp.com/store/

Ecng.Backup.Yandex

Ecng system framework

StockSharp.Studio.WebApi

Community types. More info on web site https://stocksharp.com/store/

Ecng.Backup.AWS

Ecng system framework

Ecng.Backup.Mega

Ecng system framework

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.263 215 3/3/2026
1.0.262 211 2/28/2026
1.0.261 294 2/4/2026
1.0.260 252 2/1/2026
1.0.259 365 1/22/2026
1.0.258 288 1/19/2026
1.0.257 317 1/18/2026
1.0.256 244 1/18/2026
1.0.255 251 1/14/2026
1.0.254 243 1/13/2026
1.0.253 256 1/13/2026
1.0.252 306 1/9/2026
1.0.251 361 1/4/2026
1.0.250 251 12/30/2025
1.0.249 245 12/29/2025
1.0.248 239 12/26/2025
1.0.247 237 12/26/2025
1.0.246 239 12/26/2025
1.0.245 247 12/26/2025
1.0.244 321 12/25/2025
Loading failed