(PureBasic) Move File to Another Directory on Server
Moves a file from one directory to another. This is accomplished by renaming the file using a filepath that includes the directory.
IncludeFile "CkFtp2.pb"
Procedure ChilkatExample()
; This example requires the Chilkat API to have been previously unlocked.
; See Global Unlock Sample for sample code.
ftp.i = CkFtp2::ckCreate()
If ftp.i = 0
Debug "Failed to create object."
ProcedureReturn
EndIf
CkFtp2::setCkHostname(ftp, "ftp.example.com")
CkFtp2::setCkUsername(ftp, "login")
CkFtp2::setCkPassword(ftp, "password")
; Connect and login to the FTP server.
success.i = CkFtp2::ckConnect(ftp)
If success <> 1
Debug CkFtp2::ckLastErrorText(ftp)
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndIf
; Rename the remote file (or directory)
existingFilepath.s = "dirA/hello.txt"
newFilepath.s = "dirB/hello.txt"
success = CkFtp2::ckRenameRemoteFile(ftp,existingFilepath,newFilepath)
If success <> 1
Debug CkFtp2::ckLastErrorText(ftp)
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndIf
success = CkFtp2::ckDisconnect(ftp)
CkFtp2::ckDispose(ftp)
ProcedureReturn
EndProcedure
|