Sample code for 30+ languages & platforms
Objective-C

Delete Remote File

See more FTP Examples

Delete a remote file.

Chilkat Objective-C Downloads

Objective-C
#import <CkoFtp2.h>

BOOL success = NO;

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

CkoFtp2 *ftp = [[CkoFtp2 alloc] init];

ftp.Hostname = @"ftp.chilkatsoft.com";
ftp.Username = @"myLogin";
ftp.Password = @"myPassword";

// Connect and login to the FTP server.
success = [ftp Connect];
if (success != YES) {
    NSLog(@"%@",ftp.LastErrorText);
    return;
}

// Set the current remote directory to where the file
// is located:
success = [ftp ChangeRemoteDir: @"/testing"];
if (success != YES) {
    NSLog(@"%@",ftp.LastErrorText);
    return;
}

success = [ftp DeleteRemoteFile: @"goodbye.txt"];
if (success != YES) {
    NSLog(@"%@",ftp.LastErrorText);
    return;
}

success = [ftp Disconnect];