Visual FoxPro
Visual FoxPro
Delete FTP Directory Tree
See more FTP Examples
Delete an entire directory tree on an FTP server.Chilkat Visual FoxPro Downloads
LOCAL lnSuccess
LOCAL loFtp
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.yourftpserver.com"
loFtp.Username = "****"
loFtp.Password = "****"
* Connect and login to the FTP server.
lnSuccess = loFtp.Connect()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Set the current remote directory to the root of
* the tree to be deleted
lnSuccess = loFtp.ChangeRemoteDir("/something")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* Delete the entire tree. All sub-directories and files are deleted.
lnSuccess = loFtp.DeleteTree()
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
* The /something directory still exists. To delete it,
* we move up one directory level and then delete it.
lnSuccess = loFtp.ChangeRemoteDir("..")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
lnSuccess = loFtp.RemoveRemoteDir("something")
IF (lnSuccess <> 1) THEN
? loFtp.LastErrorText
RELEASE loFtp
CANCEL
ENDIF
lnSuccess = loFtp.Disconnect()
RELEASE loFtp