Unicode C++
Unicode C++
Save String Variable to File on FTP Server
See more FTP Examples
Save the contents of a string variable to a file on an FTP server.Chilkat Unicode C++ Downloads
#include <CkFtp2W.h>
void ChilkatSample(void)
{
bool success = false;
// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
CkFtp2W ftp;
ftp.put_Hostname(L"ftp.example.com");
ftp.put_Username(L"login");
ftp.put_Password(L"password");
// Connect and login to the FTP server.
success = ftp.Connect();
if (success != true) {
wprintf(L"%s\n",ftp.lastErrorText());
return;
}
// Change to the remote directory where the existing file is located.
success = ftp.ChangeRemoteDir(L"junk");
if (success != true) {
wprintf(L"%s\n",ftp.lastErrorText());
return;
}
// Upload the contents of a string to a remote file.
const wchar_t *fileContents = L"To be, or not to be: that is the question.";
const wchar_t *remoteFilename = L"hamletQuote.txt";
success = ftp.PutFileFromTextData(remoteFilename,fileContents);
if (success != true) {
wprintf(L"%s\n",ftp.lastErrorText());
return;
}
success = ftp.Disconnect();
wprintf(L"String Uploaded!\n");
}