Skip to content

Automatic Connection

Robinicks edited this page Feb 5, 2020 · 24 revisions

API

  • AutoDetect() - Automatically discover working FTP connection settings and return those connection profiles.

  • AutoConnect() - Automatically discover working FTP connection settings and use those to connect to the server.

How do I auto-detect the correct connection settings?

Use this code:

FtpClient client = new FtpClient(hostname, username, password); // or set Host & Credentials
var profiles = client.AutoDetect();

// if any profiles are found, print the code to the console
if (profiles.Count > 0){
	var code = profiles[0].ToCode();
	Console.WriteLine(code);
}

Once you find a working connection profile, use the generated code to quickly connect to your FTP server.

How do I auto-connect to an FTP or FTPS server?

Use this code:

FtpClient client = new FtpClient(hostname, username, password); // or set Host & Credentials
client.AutoConnect();
Clone this wiki locally