React Native
React Native
Delete Remote File
See more FTP Examples
Delete a remote file.Chilkat React Native Downloads
import { Ftp2 } from '@chilkat/react-native'
async function chilkatExample() {
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const ftp = new Ftp2();
ftp.hostname = 'ftp.chilkatsoft.com';
ftp.username = 'myLogin';
ftp.password = 'myPassword';
// Connect and login to the FTP server.
try {
await ftp.connectAsync();
} catch {
console.log(ftp.lastErrorText);
return;
}
// Set the current remote directory to where the file
// is located:
try {
await ftp.changeRemoteDirAsync('/testing');
} catch {
console.log(ftp.lastErrorText);
return;
}
try {
await ftp.deleteRemoteFileAsync('goodbye.txt');
} catch {
console.log(ftp.lastErrorText);
return;
}
await ftp.disconnectAsync();
}