Click or drag to resize

Ftp.dll - How to start

After installation, this class reference, C# and VB.NET examples can be found in your Start menu.

Go here for licensing and general help, and here for ordering.

Note Note

If you need help, please visit our technical Q&A forum. You can find many samples online.

Add reference and namespaces

First you have to add reference to Ftp.dll to your project. See MSDN how to. Then add all namespaces you need:

// C#

using Limilabs.FTP.Client;
Upload and download files from FTP server
// C#

using (Ftp client = new Ftp())
{
    client.Connect("ftp.example.org");       // or ConnectSSL for SSL
    client.Login("username", "password");

    // Upload the 'test.zip' file to the current folder on the server
    client.Upload("test.zip", @"c:\test.zip");

    // Upload the 'index.html' file to the specified folder on the server
    client.Upload("/wwwroot/index.html", @"c:\index.html");

    // Download the 'test.zip' file from the current folder on the server
    client.Download("test.zip", @"c:\test2.zip");

    // Download the 'index.html' file from the specified folder on the server
    client.Download("/wwwroot/index.html", @"c:\index.html");

    // upload in memory text
    const string message = "Hello from Ftp.dll";
    byte[] data = Encoding.Default.GetBytes(message);
    client.Upload("message.txt", data);

    client.Close();
}
List files and folders
// C#

using (Ftp client = new Ftp())
{
    client.Connect("ftp.example.org");
    client.Login("username", "password");

    // select the desired folder
    client.ChangeFolder("path");

    // retrieve and display the list of files and directories
    List<FtpItem> list = client.GetList();

    foreach (FtpItem item in list)
    {
        Console.Write(item.ModifyDate.ToString());
        Console.Write(item.Size.ToString().PadLeft(10, ' '));
        if (item.IsFolder == true)
            Console.Write(" [{0}]", item.Name);
        else
            Console.Write(" {0}", item.Name);
        Console.WriteLine();
    }
    client.Close();
}
Use SSL with FTP (FTPS)
// C#

using (Ftp client = new Ftp())
{
    // Use this line to validate self-signed certificates:
    client.ServerCertificateValidate += ValidateCertificate;

    client.ConnectSSL("ftp.example.org");
    client.Login("username", "password");

    foreach (FtpItem item in client.GetList())
    {
        Console.WriteLine("{0}", item.Name);
    }
    client.Close();
}

private static void ValidateCertificate(
    object sender,
    ServerCertificateValidateEventArgs e)
{
    const SslPolicyErrors ignoredErrors =
        SslPolicyErrors.RemoteCertificateChainErrors |
        SslPolicyErrors.RemoteCertificateNameMismatch;

    if ((e.SslPolicyErrors & ignoredErrors) != 0)
    {
      e.IsValid = true;
      return;
    }
    e.IsValid = false;
}
Samples online
Note Note

If you need help, please visit our technical Q&A forum. You can find many samples online.