I observe an interesting behaviour. There are two .net 2.0 assemblies that use Rebex Rebex.Net component to send files to an SFTP server. One works fine, VB.NET, but the other, C# doesn't. I am able to login to the server, locate the destination folder, but get an exeption o PutFile method. They both called by the same Windows .net 2.0 VB.NET application. Insights are very welcome. Thank you.
private SftpFileSentStatus SendSftpTestFile(MGAManager mga, string pFileName, string sURI)
{
SftpFileSentStatus fileTransferStatus = SftpFileSentStatus.None;
Sftp client = null;
if (System.IO.File.Exists(pFileName))
{
try
{
client = new Sftp();
client.Connect(mga.FTPServer);
client.Login(mga.FTPUser, mga.FTPPassword);
client.PutFile(pFileName, sURI);
fileTransferStatus = SftpFileSentStatus.Success;
}
catch (Exception ex)
{
fileTransferStatus = SftpFileSentStatus.Failed;
}
finally
{
if (client.State == SftpState.Connected || client.State == SftpState.Ready)
client.Disconnect(); client.Dispose();
}
}
else fileTransferStatus = SftpFileSentStatus.Inconclusive;
return fileTransferStatus;
}
Here is the stack trace:
at Rebex.Net.SftpCore.ThrowOnError(Packet packet, Type expected)
at Rebex.Net.SftpCore.Open(String path, SftpOpenMode mode, Boolean failOnError)
at Rebex.Net.Sftp.PutFileInternal(SftpOpenMode mode, Object state, String remotePath, Stream sourceStream, Int64 remoteOffset, Int64 length)
at Rebex.Net.Sftp.PutFileInternal(SftpOpenMode mode, Object state, String remotePath, String localPath, Int64 remoteOffset, Int64 localOffset, Int64 length)
at Rebex.Net.Sftp.PutFile(String localPath, String remotePath)
at InstallationDiagnostics.InstallationTests.SendSftpTestFile(MGAManager mga, String pFileName, String sURI) in C:\Documents and Settings\svasily\My Documents\Visual Studio 2008\Projects\MGA XML Extracts\InstallationDiagnostics\InstallationTests.cs:line 275