I forgot to add some information of exactly what piece of code I am using.
my log shows "Connecting..", then I see the exception "Exception caught in BBGenDataApplication.Utils.uploadFile: Server response does not contain SSH protocol identification."
so it could be the connect fails, or it connected, and the ChangeDirectory() fails..
I'll have to put a debug line right after the connect.
Still, the problem is, why it sometimes fails, and sometimes it doesn't?
and in re-attempt, the same file transmission works most of the time.
Thanks
Cecilia
The program fails right after
my log shows "Connecting..", then I see the exception "Exception caught in BBGenDataApplication.Utils.uploadFile: Server response does not contain SSH protocol identification."
so it could be the connect fails, or it connected, and the ChangeDirectory() fails..
I'll have to put a debug line right after the connect.
Still, the problem is, why it sometimes fails, and sometimes it doesn't?
and in re-attempt, the same file transmission works most of the time.
Thanks
Cecilia
The program fails right after
public static void uploadFile(String uploadLongFileName)
{
try
{
// FTP_SERVER, FTP_USER, FTP_PASSWORD are set previously
// upload a file
using (var sftp = new SftpClient(FTP_SERVER, FTP_USER, FTP_PASSWORD))
{
Utils.doLog("Connecting...");
sftp.Connect();
//(@"/POLP-To-FDC/");
sftp.ChangeDirectory(@"/POLP-To-FDC/");
Utils.doLog("moved to dir...");
// upload the file
using (var filestream = File.OpenRead(uploadLongFileName))
{
// upload the file, cannot override (should not need it)
sftp.UploadFile(filestream, uploadShortFilename, false);
Utils.doLog("uploaded file...");
}
sftp.Disconnect();
}
}
catch (Exception ex)
{
errMessage = "Exception caught in " + methodName + ": " + ex.Message;
Utils.handleCriticalError(errMessage);
}
}