Swift
Swift
Remove Directory
See more FTP Examples
Delete a remote FTP directory.Chilkat Swift Downloads
func chilkatTest() {
var success: Bool = false
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let ftp = CkoFtp2()!
ftp.hostname = "ftp.example.com"
ftp.username = "login"
ftp.password = "password"
// Connect and login to the FTP server.
success = ftp.connect()
if success != true {
print("\(ftp.lastErrorText!)")
return
}
// Delete a directory on the FTP server. The directory
// must not contain any files, otherwise an error status
// will be returned. Most FTP servers do not allow
// directories containing files to be deleted.
success = ftp.removeRemoteDir(dir: "newDirName")
if success != true {
print("\(ftp.lastErrorText!)")
return
}
success = ftp.disconnect()
}