Xbase++
Xbase++
Delete a Remote FTP File (DELE)
See more FTP Examples
Demonstrates the Chilkat Ftp2.DeleteRemoteFile method, which deletes a remote file. The only argument is the remote file path, relative to the current directory or absolute.
Background: Deletion is immediate and permanent — FTP has no trash or undo — so a job that removes files should be certain of the path first. Whether it is allowed depends on the account's permissions on the file and its containing directory. Note that a successful delete does not refresh the cached indexed listing.
Chilkat Xbase++ Downloads
LOCAL nSuccess
LOCAL oFtp
nSuccess := 0
// Demonstrates the Ftp2.DeleteRemoteFile method, which deletes a remote file. The only argument
// is the remote file path (relative to the current directory or absolute).
oFtp := CreateObject("Chilkat.Ftp2")
oFtp:Hostname := "ftp.example.com"
oFtp:Username := "myFtpLogin"
// Normally you would not hard-code the password in source. You should instead obtain it
// from an interactive prompt, environment variable, or a secrets vault.
oFtp:Password := "myPassword"
nSuccess := oFtp:Connect()
IF (nSuccess == 0)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
nSuccess := oFtp:ChangeRemoteDir("public_html")
IF (nSuccess == 0)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
nSuccess := oFtp:DeleteRemoteFile("uploads/obsolete.tmp")
IF (nSuccess == 0)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
? "File deleted."
nSuccess := oFtp:Disconnect()
IF (nSuccess == 0)
? oFtp:LastErrorText
oFtp:destroy()
RETURN
ENDIF
oFtp:destroy()