Unicode C
Unicode C
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 Unicode C Downloads
#include <C_CkFtp2W.h>
void ChilkatSample(void)
{
BOOL success;
HCkFtp2W ftp;
const wchar_t *existingFilepath;
const wchar_t *newFilepath;
success = FALSE;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
ftp = CkFtp2W_Create();
CkFtp2W_putHostname(ftp,L"ftp.example.com");
CkFtp2W_putUsername(ftp,L"login");
CkFtp2W_putPassword(ftp,L"password");
// Connect and login to the FTP server.
success = CkFtp2W_Connect(ftp);
if (success != TRUE) {
wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
CkFtp2W_Dispose(ftp);
return;
}
// Rename the remote file (or directory)
existingFilepath = L"dirA/hello.txt";
newFilepath = L"dirB/hello.txt";
success = CkFtp2W_RenameRemoteFile(ftp,existingFilepath,newFilepath);
if (success != TRUE) {
wprintf(L"%s\n",CkFtp2W_lastErrorText(ftp));
CkFtp2W_Dispose(ftp);
return;
}
success = CkFtp2W_Disconnect(ftp);
CkFtp2W_Dispose(ftp);
}