Xbase++
Xbase++
Quote and SendCommand
See more FTP Examples
Demonstrate the Quote and SendCommand methods.Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFtp
LOCAL cServerResponse
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
// Tell the FTP object to keep an in-memory session log
// so we can see the commands sent to the server,
// and the responses received back.
oFtp:KeepSessionLog := 1
// Change the current remote directory via the Quote method:
nSuccess := oFtp:Quote("CWD junk")
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
// Move back up
// In this case, ChangeRemoteDir sends "CWD .." to the FTP server.
nSuccess := oFtp:ChangeRemoteDir("..")
IF (nSuccess != 1)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
// Do the same via the SendCommand method where the
// raw FTP server response is returned:
cServerResponse := oFtp:SendCommand("CWD junk")
IF (oFtp:LastMethodSuccess != 1)
? oFtp:LastErrorText
ELSE
? cServerResponse
ENDIF
nSuccess := oFtp:Disconnect()
? "Session Log:"
? oFtp:SessionLog
oFtp:destroy()