Zhaobang.FtpServer 2.1.3

dotnet add package Zhaobang.FtpServer --version 2.1.3
NuGet\Install-Package Zhaobang.FtpServer -Version 2.1.3
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="Zhaobang.FtpServer" Version="2.1.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Zhaobang.FtpServer --version 2.1.3
#r "nuget: Zhaobang.FtpServer, 2.1.3"
#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.
// Install Zhaobang.FtpServer as a Cake Addin
#addin nuget:?package=Zhaobang.FtpServer&version=2.1.3

// Install Zhaobang.FtpServer as a Cake Tool
#tool nuget:?package=Zhaobang.FtpServer&version=2.1.3

Zhaobang.FtpServer

A FTP library for .NET Standard 1.4 and .NET Standard 2.1.

Build Status: Build status

Get stable release: Get stable release

Get testing release: Get testing release

Simple Usage

The server allows anonymous login, and users can read and write in a public directory.

To start the server

// using System.Net;
// using System.Threading;
// using Zhaobang.FtpServer;

var endPoint = new IPEndPoint(IPAddress.Any, 21);
// To accept IPv6 connection, replace "IPAddress.Any" with "IPAddress.IPv6Any"
// You need 2 FtpServer instances to accept both IPv4 and IPv6 connectins

var baseDirectory = "C:\\FtpServer";
var server = new FtpServer(endPoint, baseDirectory);

var cancelSource = new CancellationTokenSource();
var runResult = server.RunAsync(cancelSource.Token);

To stop the server

cancelSource.Cancel(); // Stop accepting new clients
await runResult; // Wait until last client quits

Customization

The server allows developer to use customized authentication, file provider, data connection and stream encrytion.

Implement Zhaobang.FtpServer.File.IFileProviderFactory to use custom file system. The default one is SimpleFileProvider, which allow all users to read and write in a single directory.

Implement Zhaobang.FtpServer.Connections.IDataConnectionFactory to use custom data connection, (for example, establish data connection from another server). The default one is LocalDataConnectionFactory, which establish data connection from local server. Use SslLocalDataConnectionFactory (available only on .NET Standard 2.1) to support TLS on data connection.

Implement Zhaobang.FtpServer.Authenticate.IAuthenticator to use custom authentication. The default one is AnonymousAuthenticator, which only allows anonymous logins.

(Optional) (since version 2.1.0) Provide an implementation of Zhaobang.FtpServer.Connections.IControlConnectionSslFactory to support TLS on control connection. An implementation class ControlConnectionSslFactory is provided on the .NET Standard 2.1 version.

Use the following to start your customized server:

var server = new FtpServer(
    localEP,
    new MyFileProviderFactory(),
    new MyDataConnectionFactory(),
    new MyAuthenticator(),
    new MyControlConnectionSslFactory()
);
// the remaining is same as simple use

FTP over TLS support (since version 2.1.0)

TLS on data connection is enabled when IDataConnection instances created by IDataConnectionDataFactory instance implement interface ISslDataConnection.

TLS on control connection is enabled when an instance of IControlConnectionSslFactory is passed to the constructor of FtpServer.

The .NET Standard 2.1 version has out-of-box FTP over TLS support. Example:

var fileProviderFactory = new SimpleFileProviderFactory(config.BaseDirectory);
var dataConnectionFactory = new SslLocalDataConnectionFactory(certificate);
var authenticator = new AnonymousAuthenticator();
var controlConnectionSslFactory = new ControlConnectionSslFactory(certificate);
var server = new FtpServer(ep, fileProviderFactory, dataConnectionFactory, authenticator, controlConnectionSslFactory);

The .NET Standard 1.4 version requires your own implementation of those classes. You can refer to the source code for a sample implementation.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.NET Core netcoreapp1.0 was computed.  netcoreapp1.1 was computed.  netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard1.4 is compatible.  netstandard1.5 was computed.  netstandard1.6 was computed.  netstandard2.0 was computed.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen30 was computed.  tizen40 was computed.  tizen60 was computed. 
Universal Windows Platform uap was computed.  uap10.0 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos 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
2.1.3 768 4/18/2023
2.1.2 2,216 6/13/2020
2.1.1 669 4/14/2020
2.1.0 781 10/6/2019
2.0.0 1,390 10/17/2017
1.0.0 1,004 9/26/2017

2.1.3:
Fix compatibility with clients that add "-a" flag in LIST command.

2.1.2:
Fix the error of handling encoding (command "opts utf8 on").

2.1.1:
Fix the error of handling client quitting.

2.1.0:
Support FTP over TLS (requires implementing interfaces except on .NET Standard 2.1).
Support tracing user activities.

2.0.0:
Add extensibility for supporting more protocals
Add support of IPv6
Support LIST command for a file
Structure in 1.0.0 are changed for better extensibility
Bug fix