Skip to content

PatrickHofman/FtpServer

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Portable FTP server

Build status

This FTP server is written as .NET Standard 2.0 library and has an abstract file system which allows e.g. Google Drive as backend.

License

The library is released under the MIT license.

Prerequisites

Compilation

  • Visual Studio 2017 / C# 7.2

Using

  • Visual Studio 2017
  • .NET Standard 2.0

NuGet packages

Description Badge
FubarDev.FtpServer: Core library FubarDev.FtpServer
FD.FS.Abstractions: Basic types FubarDev.FtpServer.Abstractions
FD.FS.FileSystem.DotNet: System.IO-based file system FubarDev.FtpServer.FileSystem.DotNet
FD.FS.FileSystem.GoogleDrive: Google Drive as file system FubarDev.FtpServer.FileSystem.GoogleDrive

Example FTP server

Creating the project

dotnet new console
dotnet add package FubarDev.FtpServer.FileSystem.DotNet
dotnet add package FubarDev.FtpServer
dotnet add package Microsoft.Extensions.DependencyInjection

Contents of Main in Program.cs

// Setup dependency injection
var services = new ServiceCollection();

// use %TEMP%/TestFtpServer as root folder
services.Configure<DotNetFileSystemOptions>(opt => opt
    .RootPath = Path.Combine(Path.GetTempPath(), "TestFtpServer"));

// Add FTP server services
// DotNetFileSystemProvider = Use the .NET file system functionality
// AnonymousMembershipProvider = allow only anonymous logins
services.AddFtpServer(builder => builder
    .UseDotNetFileSystem() // Use the .NET file system functionality
    .EnableAnonymousAuthentication()); // allow anonymous logins

// Configure the FTP server
services.Configure<FtpServerOptions>(opt => opt.ServerAddress = "127.0.0.1");

// Build the service provider
using (var serviceProvider = services.BuildServiceProvider())
{
    // Initialize the FTP server
    var ftpServer = serviceProvider.GetRequiredService<IFtpServer>();

    // Start the FTP server
    ftpServer.Start();
    
    Console.WriteLine("Press ENTER/RETURN to close the test application.");
    Console.ReadLine();
    
    // Stop the FTP server
    ftpServer.Stop();
}

Packages

No packages published

Languages

  • C# 100.0%