-
-
Notifications
You must be signed in to change notification settings - Fork 657
Automatic Connection
Tip: For detailed documentation refer to the IntelliSense tips that appear when you call a given API method.
-
AutoConnect() - Automatically discover working FTP connection settings and use those to connect to the server. This method will intelligently try certain combinations of connection settings until it finds a working combination. The connection types are tried in this order of preference.
-
AutoDetect() - Automatically discover working FTP connection settings and return those connection profiles. This method will intelligently try certain combinations of connection settings until it finds a working combination, and it will return the first found combination or all found combinations. The connection types are tried in this order of preference.
Use this code:
FtpClient client = new FtpClient(hostname, username, password); // or set Host & Credentials
client.AutoConnect();
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.
Auto connection attempts to find working connection settings in this order of preference:
Protocol Preference:
- Explicit FTPS (TLS) - very common
- Plaintext FTP - very common
- Implicit FTPS (SSL) - outdated and very rare
FTPS Protocol Preference:
-
Tls12 | Tls11
- TLS 1.2 or TLS 1.1 (TLS 1.3 is not yet stable in .NET Framework) -
Tls
- TLS 1.0 -
Default
- Undefined/weird behaviour
Data Connection Type Preference:
- For servers connected over IPV6, we use
EPSV
(enhanced passive) - For servers connected over IPV4, we try
PASV
(passive) which has the widest support on FTP servers
Encoding Type Preference:
-
UTF8
- We always use Unicode if it can be supported by the server
Auto connection automatically calculates the best values for the following properties in FtpClient
:
- Port (unless a non-standard port is specified before calling
AutoConnect
) - EncryptionMode
- SslProtocols
- DataConnectionType
- Encoding
- Auto Connection
- Auto Reconnection
- FTP(S) Connection
- FTP(S) Connection using GnuTLS
- FTPS Proxies
- Custom Servers
- Custom Commands
- v40 Migration Guide