Visual FoxPro
Visual FoxPro
Quote and SendCommand
See more FTP Examples
Demonstrate the Quote and SendCommand methods.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loFtp
LOCAL lcServerResponse
lnSuccess = 0
* This example requires the Chilkat API to have been previously unlocked.
* See Global Unlock Sample for sample code.
loFtp = CreateObject('Chilkat.Ftp2')
loFtp.Hostname = "ftp.example.com"
loFtp.Username = "login"
loFtp.Password = "password"
* Connect and login to the FTP server.
lnSuccess = loFtp.Connect()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
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.
loFtp.KeepSessionLog = 1
* Change the current remote directory via the Quote method:
lnSuccess = loFtp.Quote("CWD junk")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Move back up
* In this case, ChangeRemoteDir sends "CWD .." to the FTP server.
lnSuccess = loFtp.ChangeRemoteDir("..")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Do the same via the SendCommand method where the
* raw FTP server response is returned:
lcServerResponse = loFtp.SendCommand("CWD junk")
IF (loFtp.LastMethodSuccess <> 1) THEN
? loFtp.LastErrorText
ELSE
? lcServerResponse
ENDIF
lnSuccess = loFtp.Disconnect()
? "Session Log:"
? loFtp.SessionLog
RELEASE loFtp