Xbase++
Xbase++
Move File to Another Directory on Server
See more FTP Examples
Moves a file from one directory to another. This is accomplished by renaming the file using a filepath that includes the directory.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFtp
LOCAL cExistingFilepath
LOCAL cNewFilepath
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
// Rename the remote file (or directory)
cExistingFilepath := "dirA/hello.txt"
cNewFilepath := "dirB/hello.txt"
nSuccess := oFtp:RenameRemoteFile(cExistingFilepath, cNewFilepath)
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
nSuccess := oFtp:Disconnect()
oFtp:destroy()