Rename (rename/move a file)

function Rename(oldName, newName: string): boolean

The Rename function renames (or move) a file. The oldName file must exist, and the newName file must not exist, otherwise this command will fail and return false. If the command succeeds, and the file is successfully renamed/moved, then this function will return true.

Example:

{
  var cli = new SftpClient();
  cli.Host = 'your.sftpserver.com:22';
  cli.User = 'someusername';
  cli.KeyFile = './my_id.rsa';
  if (cli.Connect()) {
    // ...
    if (cli.Rename('/docs/budget2020.xlsx', '/docs/budget2021.xlsx')) {
      Log('file was successfully renamed');
    }
    // ...
    cli.Close();
  }
  cli = null
}