Connect

function Connect(): boolean

The Connect() function tries to connect and authenticate to the remote service. If such connection and authentication are successful, this function returns true, otherwise it returns false.

{
  var cli = new SftpClient();
  cli.Host = 'your.sftpserver.com:22';
  cli.User = 'someusername';
  cli.KeyFile = './my_id.rsa';
  if (cli.Connect()) {
    // perform your file transfers...
    // ...
    // ...
    cli.Close();
  }
  cli = null
}