edtFTPnet/PRO - Secure FTP component for .NET | Free Trial | Pricing
Connect to the FTP server.

Namespace: EnterpriseDT.Net.Ftp
Assembly: edtFTPnetPRO (in edtFTPnetPRO.dll) Version: 9.4.0.40

Syntax

C#
public override void Connect()
Visual Basic
Public Overrides Sub Connect
Visual C++
public:
virtual void Connect() override

Remarks

If this component is being used on a form or within another component then it is a good idea to use the "Connection Tester" to test the property settings.

Connections are not opened until the Connect()()()() method is called. Connection-, Authentication-, and Security-related properties should be set prior to opening the connection.

At a minimum, the following properties should be set prior to connection.

PropertyDescription
ProtocolThe protocol to use: SFTP, explicit FTPS, implicit FTPS or plain FTP.
ServerAddressThe domain-name or IP-address of the server.
UserNameUser-name of account on the server.
PasswordPassword of account on the server.

FTPS: If explicit FTPS has been selectedand AutoSecure is true (the default) then the component will try to secure the connection immediately after successfully connecting. A secure connection will always be attempted in implicit FTPS is selected regardless of the value of AutoSecure.

Examples

The following example illustrates the establishment of an explicit FTPS connection using automatic server validation
 Copy imageCopy
               SecureFTPConnection ftp = new SecureFTPConnection();
               ftp.Protocol = FileTransferProtocol.FTPSExplicit;
               ftp.ServerAddress = "my-server-name";
               ftp.UserName = "my-username";
               ftp.Password = "my-password";
               ftp.ServerValidation = SecureFTPServerValidationType.Automatic;
               // the server's certificate must have been previously registered with
               // the operating system (see class description)
               ftp.Connect();
               ftp.Close();
             

SFTP: SFTP connections always require some kind of authentication; this may be set using the AuthenticationMethod property. Server validation is optional, but recommended; it is selected using the ServerValidation property.

Examples

The following example illustrates an SFTP client connecting to a server using simple password authentication but no server validation:
 Copy imageCopy
               SecureFTPConnection ftp = new SecureFTPConnection();
               ftp.Protocol = FileTransferProtocol.SFTP;
               ftp.ServerAddress = "my-server-name";
               ftp.UserName = "my-username";
               ftp.Password = "my-password";
               ftp.AuthenticationMethod = AuthenticationType.Password;
               ftp.ServerValidation = SecureFTPServerValidationType.None;
               ftp.Connect();
               ftp.Close();
             

Examples

This example illustrates an SFTP client using public key authentication connecting to a server:
 Copy imageCopy
               SecureFTPConnection ftp = new SecureFTPConnection();
               ftp.Protocol = FileTransferProtocol.SFTP;
               ftp.ServerAddress = "my-server-name";
               ftp.UserName = "my-username";
               ftp.AuthenticationMethod = AuthenticationType.PublicKey;
               ftp.ClientPrivateKeyFile = "pathtokeyfile";
               ftp.ClientPrivateKeyPassphrase = "passwordforkeyfile";
               ftp.ServerValidation = SecureFTPServerValidationType.None;
               ftp.Connect();
               ftp.Close();
             

This method will throw an FTPException if the component is already connected to the server.

See Also