Back to feature list...

FTP server

Rebex File Server can be used to easily add FTP server capabilities to your .NET application, no matter whether you use C#, VB.NET or any other .NET language.

Launching an FTP server 

Simply create an instance of FileServer, bind it to a port, add a server certificate and at least one user with a path to their root directory. Then start it, and the fully working secure FTP server is ready:

// create a server instance
var server = new FileServer();

// bind FTP to port 21 (secured by TLS)
server.Bind(21, FileServerProtocol.Ftp);

// load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword));

// add a user (specify username, password and virtual root path)
server.Users.Add("user01", "userPassword", @"c:\data\user01");

// start the server in the background
server.Start();
' create a server instance
Dim server = New FileServer()

' bind FTP to port 21 (secured by TLS)
server.Bind(21, FileServerProtocol.Ftp)

' load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword))

' add a user (specify username, password and virtual root path)
server.Users.Add("user01", "password", "c:\data\user01")

' start the server in the background
server.Start()

See also

TLS modes 

The standard TLS mode for FTP is explicit mode, which usually runs over port 21. However, FileServer supports implicit mode as well (usually runs ove rport 990). Alternatively, the legacy plain (unsecure) FTP protocol is supported as well.

Provide FTP over TLS in explicit mode:

// bind FTP to port 21 (secured by TLS)
server.Bind(21, FileServerProtocol.Ftp);

// load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword));
' bind FTP to port 21 (secured by TLS)
server.Bind(21, FileServerProtocol.Ftp)

' load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword))

Provide FTP over TLS in implicit mode:

// bind FTP to port 990 (default port for FTP over TLS implicit)
server.Bind(990, FileServerProtocol.FtpImplicit);

// load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword));
' bind FTP to port 990 (default port for FTP over TLS implicit)
server.Bind(990, FileServerProtocol.FtpImplicit)

' load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword))

Provide all possible FTP connection modes: explicit TLS, explicit TLS, and legacy unsecure FTP (which runs over port 21 as well):

// bind FTP to port 21 (for unsecured FTP and explicit TLS)
server.Bind(21, FileServerProtocol.Ftp);
// bind FTP to port 990 (for implicit TLS)
server.Bind(990, FileServerProtocol.FtpImplicit);

// make encryption optional (allow both TLS and unsecure connections)
server.Settings.FtpControlProtection = FtpProtection.Optional;
server.Settings.FtpDataProtection = FtpProtection.Optional;

// load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword));
' bind FTP to port 21 (for unsecured FTP and explicit TLS)
server.Bind(21, FileServerProtocol.Ftp)
' bind FTP to port 990 (for implicit TLS)
server.Bind(990, FileServerProtocol.FtpImplicit)

' make encryption optional (allow both TLS and unsecure connections)
server.Settings.FtpControlProtection = FtpProtection.Optional
server.Settings.FtpDataProtection = FtpProtection.Optional

' load a server certificate from a 'cert.pfx' file
server.Certificates.Add(CertificateChain.LoadPfx("cert.pfx", certPassword))

It's also possible to only provide the old plain unsecure FTP:

// bind FTP to port 21
server.Bind(21, FileServerProtocol.Ftp);

// disable encryption for both control and data channels
server.Settings.FtpControlProtection = FtpProtection.Disabled;
server.Settings.FtpDataProtection = FtpProtection.Disabled;
' bind FTP to port 21
server.Bind(21, FileServerProtocol.Ftp)

' disable encryption for both control and data channels
server.Settings.FtpControlProtection = FtpProtection.Disabled
server.Settings.FtpDataProtection = FtpProtection.Disabled

Virtual file system 

Rebex File Server presents a virtual file system to each user. This makes it simple to configure it so that no sensitive or unwanted data are revealed - just confine each user to a specific directory (and its subtree) in the filesystem.

Tracking uploads and downloads 

Rebex File Server enables tracking of uploaded and downloaded files. To get notified when a file is uploaded or downloaded, register FileServer.FileUploaded event or FileServer.FileDownloaded event, respectively.

server.FileUploaded += server_FileUploaded;
server.FileDownloaded += server_FileDownloaded;
AddHandler server.FileUploaded, AddressOf Me.server_FileUploaded
AddHandler server.FileDownloaded, AddressOf Me.server_FileUploaded

Both events provide various information about the transfer, such as details about the user transferring the file, relative path from the user's root directory, bytes transferred, and so on.

void server_FileDownloaded(object sender, FileTransferredEventArgs e)
{
    Console.WriteLine("User '{0}' downloaded file '{1}', bytes transferred: {2}",
        e.User.Name, e.FullPath, e.BytesTransferred);
}

void server_FileUploaded(object sender, FileTransferredEventArgs e)
{
    Console.WriteLine("User '{0}' uploaded file '{1}', bytes transferred: {2}",
        e.User.Name, e.FullPath, e.BytesTransferred);
}
Private Sub server_FileDownloaded(ByVal sender As Object, ByVal e As FileTransferredEventArgs)
    Console.WriteLine("User '{0}' downloaded file '{1}', bytes transferred: {2}",
                      e.User.Name, e.FullPath, e.BytesTransferred)
End Sub

Private Sub server_FileUploaded(ByVal sender As Object, ByVal e As FileTransferredEventArgs)
    Console.WriteLine("User '{0}' uploaded file '{1}', bytes transferred: {2}",
                      e.User.Name, e.FullPath, e.BytesTransferred)
End Sub

Compatible with popular FTP clients 

Our FTP server is compatible with popular third-party FTP clients such as WinSCP, FileZilla, Total Commander...

It's a perfect companion to our FTP client library, but it works with any third-party client that supports FTP or FTP over TLS.

Back to feature list...