Xbase++
Xbase++
Rename Remote File
See more FTP Examples
Rename a remote file or directory. The RenameRemoteFile can be called to rename either a remote file or directory.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFtp
LOCAL cExistingFilename
LOCAL cNewFilename
nSuccess := 0
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
oFtp := CreateObject("Chilkat.Ftp2")
oFtp:Hostname := "ftp.example.com"
oFtp:Username := "login"
oFtp:Password := "password"
// Connect and login to the FTP server.
nSuccess := oFtp:Connect()
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
// Set the current remote directory to where the file
// is located:
nSuccess := oFtp:ChangeRemoteDir("/testing")
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
// Rename the remote file (or directory)
cExistingFilename := "hello.txt"
cNewFilename := "goodbye.txt"
nSuccess := oFtp:RenameRemoteFile(cExistingFilename, cNewFilename)
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
nSuccess := oFtp:Disconnect()
oFtp:destroy()