Sample code for 30+ languages & platforms
Dart

Delete Remote File

See more FTP Examples

Delete a remote file.

Chilkat Dart Downloads

Dart
import 'package:chilkat/chilkat.dart';

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

  final ftp = CkFtp2();

  ftp.hostname = 'ftp.chilkatsoft.com';
  ftp.username = 'myLogin';
  ftp.password = 'myPassword';

  // Connect and login to the FTP server.
  try {
    ftp.connect();
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  // Set the current remote directory to where the file
  // is located:
  try {
    ftp.changeRemoteDir('/testing');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  try {
    ftp.deleteRemoteFile('goodbye.txt');
  } on ChilkatException catch (e) {
    print(e.lastErrorText);
    return;
  }

  ftp.disconnect();
}