Sample code for 30+ languages & platforms
Swift

Delete Remote File

See more FTP Examples

Delete a remote file.

Chilkat Swift Downloads

Swift

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.chilkatsoft.com"
    ftp.username = "myLogin"
    ftp.password = "myPassword"

    // Connect and login to the FTP server.
    success = ftp.connect()
    if success != true {
        print("\(ftp.lastErrorText!)")
        return
    }

    // Set the current remote directory to where the file
    // is located:
    success = ftp.changeRemoteDir(relativeDirPath: "/testing")
    if success != true {
        print("\(ftp.lastErrorText!)")
        return
    }

    success = ftp.deleteRemoteFile(filename: "goodbye.txt")
    if success != true {
        print("\(ftp.lastErrorText!)")
        return
    }

    success = ftp.disconnect()

}