ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link
ftp

Arx One FTP

A simple FTP/FTPS/FTPES client. The client handles multiple connections and is thread safe. It also has high-level commands but supports direct command sending.

Suggestions, requests, love letters...

We are open to suggestions, don't hesitate to submit one.

How to get it

As a NuGet package.

How to use it

Instantiation

using (var ftpClient = new FtpClient(ftpUri, ftpCredentials))
{
    // ... Enjoy!
}

Commands

High-level commands

They are implemented in the form of extension methods to FtpClient

Core commands

For the hard-core developpers, here are some useful low-level commands. First of all, it is necessary to understand that the FtpClient instance can handle multiple connections at the same time (thus, it uses one separate connection to send one command). Usually it uses only one session, and reuses it command after command. You don't manipulate sessions directly but they are used by the client).

For example:

// main connection to target
using (var ftpClient = new FtpClient(new Uri("ftp://server"), new NetworkCredential("anonymous","me@me.com")))
{
    // using or creating a session
    using(var ftpSession = ftpClient.Session())
    {
        // sending a custom command
        var ftpReply = ftpSession.SendCommand("STUFF", "here", "now");
        // checkin the result. The Expect method returns the FtpReply, so SendCommand() and Expect() can be nested.
        ftpSession.Expect(ftpReply, 200, 250);
    }
}