Bitbean.Dependencies.FtpService 1.0.15

dotnet add package Bitbean.Dependencies.FtpService --version 1.0.15
                    
NuGet\Install-Package Bitbean.Dependencies.FtpService -Version 1.0.15
                    
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="Bitbean.Dependencies.FtpService" Version="1.0.15" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bitbean.Dependencies.FtpService" Version="1.0.15" />
                    
Directory.Packages.props
<PackageReference Include="Bitbean.Dependencies.FtpService" />
                    
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 Bitbean.Dependencies.FtpService --version 1.0.15
                    
#r "nuget: Bitbean.Dependencies.FtpService, 1.0.15"
                    
#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 Bitbean.Dependencies.FtpService@1.0.15
                    
#: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=Bitbean.Dependencies.FtpService&version=1.0.15
                    
Install as a Cake Addin
#tool nuget:?package=Bitbean.Dependencies.FtpService&version=1.0.15
                    
Install as a Cake Tool

FTP Service

A simple, focused service for downloading files from FTP/SFTP servers with support for multiple protocols.

Features

  • Downloads files from SFTP servers (using SSH.NET)
  • Downloads files from FTPS servers with explicit/implicit TLS/SSL encryption (using FluentFTP)
  • Automatic protocol selection based on connection configuration
  • Skips files that already exist locally with the same size
  • Provides detailed download statistics
  • Handles errors gracefully

Usage

Registration

Register the service in your Startup.cs or Program.cs:

// Add FTP service
services.AddFtpService();

Basic Usage

// Create connection info for SFTP
var sftpConnectionInfo = new FtpConnectionInfo
{
    ProtocolType = FtpProtocolType.Sftp,
    Host = "sftp.example.com",
    Username = "username",
    Password = "password",
    RemoteDirectory = "remote/directory"
    // Port will default to 22 for SFTP
};

// Create connection info for FTPS Explicit
var ftpsConnectionInfo = new FtpConnectionInfo
{
    ProtocolType = FtpProtocolType.FtpsExplicit,
    Host = "ftp.example.com",
    Username = "username",
    Password = "password",
    RemoteDirectory = "remote/directory"
    // Port will default to 21 for FTPS Explicit
};

// Download files
var result = await ftpService.DownloadFilesAsync(
    connectionInfo,
    "remote/directory",
    "local/directory",
    cancellationToken);

// Check results
Console.WriteLine($"Total files: {result.TotalFiles}");
Console.WriteLine($"Downloaded: {result.DownloadedFiles}");
Console.WriteLine($"Skipped: {result.SkippedFiles}");
Console.WriteLine($"Failed: {result.FailedFiles}");

With CompanyIntegration

If you're using the CompanyIntegration model, you can use the extension method:

// Convert from CompanyIntegration
var connectionInfo = integration.ToFtpConnectionInfo();

// Download files
var result = await ftpService.DownloadFilesAsync(
    connectionInfo,
    "remote/directory",
    "local/directory",
    cancellationToken);

Progress Tracking

Track download progress in real-time for both SFTP and FTPS with detailed metrics:

var connectionInfo = new FtpConnectionInfo
{
    ProtocolType = FtpProtocolType.Sftp,
    Host = "sftp.example.com",
    Username = "username",
    Password = "password",

    // Optional: Track download progress with detailed metrics
    ProgressCallback = progress =>
    {
        Console.WriteLine($"Progress: {progress.Progress:F1}%");
        Console.WriteLine($"Downloaded: {progress.TransferredBytes:N0} / {progress.FileSize:N0} bytes");
        Console.WriteLine($"Speed: {progress.TransferSpeedBytesPerSecond / 1024 / 1024:F2} MB/s");

        if (progress.EstimatedTimeRemaining.HasValue)
        {
            Console.WriteLine($"ETA: {progress.EstimatedTimeRemaining.Value:hh\\:mm\\:ss}");
        }

        // Update progress bar, UI, etc.
    }
};

var result = await ftpService.DownloadFileAsync(
    connectionInfo,
    "/remote/path/file.zip",
    @"C:\local\path\file.zip",
    cancellationToken);

Progress Information Available:

  • Progress - Percentage complete (0-100), or -1 if unknown
  • TransferredBytes - Number of bytes transferred so far
  • FileSize - Total file size in bytes
  • TransferSpeedBytesPerSecond - Current transfer speed
  • EstimatedTimeRemaining - Estimated time to completion (nullable)
  • LocalPath - Local file path being transferred
  • RemotePath - Remote file path being transferred

Performance Optimization for SFTP (Large Files)

For downloading large files over SFTP, you can configure performance settings:

var sftpConnectionInfo = new FtpConnectionInfo
{
    ProtocolType = FtpProtocolType.Sftp,
    Host = "sftp.example.com",
    Username = "username",
    Password = "password",

    // Performance optimizations for large file downloads
    BufferSize = 64 * 1024,                    // 64KB buffer (default)
    DisableCompression = true,                  // Disable compression for faster transfers
    PreferredCiphers = new[] { "aes128-ctr", "aes256-ctr" }, // Prioritize CTR ciphers for high-speed NICs
    InterFileDelayMilliseconds = 0,             // No delay between files (default)

    // Optional: Track progress with detailed metrics
    ProgressCallback = progress =>
    {
        Console.WriteLine($"{progress.Progress:F1}% - {progress.TransferSpeedBytesPerSecond / 1024 / 1024:F2} MB/s");
    }
};

var result = await ftpService.DownloadFileAsync(
    sftpConnectionInfo,
    "/remote/path/large-file.sqb",
    @"C:\local\path\large-file.sqb",
    cancellationToken);

Performance Notes:

  • The service uses SSH.NET's DownloadFile method which internally uses up to 100 concurrent read requests for optimal throughput
  • For large files (>100MB), these optimizations can provide 3-7x performance improvement
  • CTR ciphers (aes128-ctr, aes256-ctr) are optimized for high-speed network interfaces
  • Disabling compression reduces CPU overhead when transferring already-compressed files
  • InterFileDelayMilliseconds allows rate-limiting when downloading many files (default is 0 for maximum speed)
  • ProgressCallback works for both SFTP and FTPS protocols

Moving/Archiving Files

Move files from one location to another on the remote server (useful for archiving processed files):

// Move a file to an archive directory
bool success = await ftpService.MoveFileAsync(
    connectionInfo,
    "/remote/inbox/data.csv",
    "/remote/archive/data.csv",
    cancellationToken);

if (success)
{
    Console.WriteLine("File successfully moved to archive");
}
else
{
    Console.WriteLine("Failed to move file");
}

Notes:

  • The destination directory will be created automatically if it doesn't exist
  • For SFTP, uses SSH.NET's RenameFile method
  • For FTPS, uses FluentFTP's MoveFile method
  • Returns true on success, false on failure
  • Errors are logged but do not throw exceptions

Implementation Details

  • Uses SSH.NET for SFTP operations with optimized download methods
  • Uses FluentFTP for FTPS operations
  • Implements IAsyncEnumerable for efficient file listing
  • Handles connection and authentication errors
  • Provides detailed logging
  • Supports performance tuning for large file transfers (SFTP only)
Product Compatible and additional computed target framework versions.
.NET net8.0 is compatible.  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 is compatible.  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

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.15 277 1/14/2026
1.0.14 115 1/14/2026
1.0.13 515 1/12/2026
1.0.12 185 12/26/2025
1.0.11 366 11/7/2025
1.0.10 186 11/7/2025
1.0.9 224 11/6/2025
1.0.8 221 11/6/2025
1.0.7 237 11/4/2025
1.0.6 224 11/3/2025
1.0.5 216 11/3/2025
1.0.4 348 9/19/2025
1.0.3 275 9/19/2025
1.0.2 351 9/17/2025
1.0.1 331 9/17/2025
1.0.0 349 9/17/2025