React Native
React Native
Move File to Another Directory on Server
See more FTP Examples
Moves a file from one directory to another. This is accomplished by renaming the file using a filepath that includes the directory.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.example.com';
ftp.username = 'login';
ftp.password = 'password';
// Connect and login to the FTP server.
try {
await ftp.connectAsync();
} catch {
console.log(ftp.lastErrorText);
return;
}
// Rename the remote file (or directory)
const existingFilepath = 'dirA/hello.txt';
const newFilepath = 'dirB/hello.txt';
try {
await ftp.renameRemoteFileAsync(existingFilepath, newFilepath);
} catch {
console.log(ftp.lastErrorText);
return;
}
await ftp.disconnectAsync();
}