works great and I pull the file right to my C drive. It is only on the upload that I recieve the error in my catch "Cannot send data to server". This is pretty vague so I don't know what part is not right? Can someone tell me if they see anything in this code that could be causing this error?
This was built on RAD Studio XE2
Code: Select all
bool TfrmFTPSend::SendSFTPFile(UnicodeString host, UnicodeString user, UnicodeString pass, UnicodeString locFile)
{
bool successful = true;
TScFileStorage *KeyFileStorage = new TScFileStorage(this);
SSHClient->KeyStorage = KeyFileStorage;
SSHClient->Authentication = atPassword;
SSHClient->Port = 22;
SSHClient->HostName = host;
SSHClient->User = user;
SSHClient->Password = pass;
SFTPClient->SSHClient = SSHClient;
try
{
// Initialize session
SSHClient->Connect();
SFTPClient->Initialize();
// send file
SFTPClient->UploadFile(locFile, L"", false);
}
catch (Exception &E)
{
ErrMsg(ETYPE_ERROR, 0, E.Message, "", "");
successful = false;
}
catch (...)
{
successful = false;
}
// Finish/cleanup
SFTPClient->Disconnect();
SSHClient->Disconnect();
delete SFTPClient;
delete SSHClient;
delete KeyFileStorage;
return successful;
}