I'm trying to upload files to a bank server. What's happening is that the bank moves the file as soon it is received it so edtFTPnet throws a file not found exception. I read on this forum that using SSHDisableChmodAfterPut would prevent this from happening but it doesn't seem to work. How can I stop this from happening or catch this particular exception? Code and logs follow.
Thanks in advance for any help.
ftpConnection.Protocol = EnterpriseDT.Net.Ftp.FileTransferProtocol.SFTP;
ftpConnection.AuthenticationMethod = EnterpriseDT.Net.Ssh.AuthenticationType.PublicKey;
ftpConnection.Timeout = 2000;
ftpConnection.TransferType = EnterpriseDT.Net.Ftp.FTPTransferType.ASCII;
//this may be needed b/c BOA moves the files as soon as they are received
ftpConnection.StrictReturnCodes = false;
ftpConnection.ServerValidation = EnterpriseDT.Net.Ftp.SecureFTPServerValidationType.None;
ftpConnection.Password = string.Empty; // If I leave this out, I get an InvalidOperationException that "Password property is not set".
EnterpriseDT.Util.Debug.Logger.CurrentLevel = EnterpriseDT.Util.Debug.Level.ALL;
EnterpriseDT.Util.Debug.Logger.AddAppender(new EnterpriseDT.Util.Debug.FileAppender(Utils.CurrentLogFileName() + ".ftplog"));
//upload the paymode files
ftpConnection.ServerAddress = Config.GetAppSetting("PayModeFtpUrl", "bankofamerica.com");
ftpConnection.ClientPrivateKeyFile = Config.GetAppSetting("PayModePPKFile", "");
ftpConnection.UserName = Config.GetAppSetting("PayModeUserID", "@");
ftpConnection.ServerCompatibility = EnterpriseDT.Net.Ftp.SecureFTPCompatibilityFlags.SSHDisableChmodAfterPut;
try
{
paymode_file = Config.GetAppSetting("OutgoingFilesPath", "Outgoing") + "\\"+dtstamp+"_Paymode.csv";
ftpConnection.Connect();
filename = new FileInfo(paymode_file).Name;
filedir = new FileInfo(paymode_file).Directory.Name;
ftpConnection.UploadFile(paymode_file, filename);
Utils.WriteToLog("sent " + paymode_file + " to " + ftpConnection.ServerAddress, true, true, false, Utils.LogMessageType.Message);
ftpConnection.Close();
}
DEBUG [FTPConnection] 26 Apr 2011 22:39:15.699 : Set LocalDirectory='C:\Windows\system32'
DEBUG [SecureFTPConnection] 26 Apr 2011 22:39:15.699 : Set LocalDirectory to C:\Windows\system32
DEBUG [HostNameResolver] 26 Apr 2011 22:39:15.708 : Resolving elink-sshftp.bankofamerica.com
DEBUG [HostNameResolver] 26 Apr 2011 22:39:15.809 : Obtained 1 addresses
DEBUG [HostNameResolver] 26 Apr 2011 22:39:15.809 : IP address: 171.161.160.130
DEBUG [HostNameResolver] 26 Apr 2011 22:39:15.809 : elink-sshftp.bankofamerica.com resolved to 171.161.160.130
DEBUG [SSHFTPClient] 26 Apr 2011 22:39:15.809 : Connecting directly to SFTP server 171.161.160.130:22
DEBUG [SSHFTPClient] 26 Apr 2011 22:39:15.865 : Connected successfully to SFTP server 171.161.160.130:22
DEBUG [SSHConnection] 26 Apr 2011 22:39:15.866 : Beginning protocol negotiation
DEBUG [PlainSocket] 26 Apr 2011 22:39:15.957 : RepeatCallback received 39 bytes
DEBUG [ProtocolNegotiationHandler] 26 Apr 2011 22:39:15.959 : offset=0,length=39
DEBUG [ProtocolNegotiationHandler] 26 Apr 2011 22:39:15.959 : Read: 'SSH-2.0-Connect:Enterprise_UNIX_2.4.02'
DEBUG [SSHUtil] 26 Apr 2011 22:39:15.960 : Major string = '2'
DEBUG [SSHUtil] 26 Apr 2011 22:39:15.960 : Minor string = '0'
DEBUG [SSHUtil] 26 Apr 2011 22:39:15.960 : Version 2.0
DEBUG [SSHUtil] 26 Apr 2011 22:39:15.960 : Protocol compatible
DEBUG [SSHConnection] 26 Apr 2011 22:39:15.960 : Server version=SSH-2.0-Connect:Enterprise_UNIX_2.4.02
DEBUG [SSH2Connection] 26 Apr 2011 22:39:15.962 : Timeout=2000
DEBUG [SSHConnection] 26 Apr 2011 22:39:15.963 : Sending client version=SSH-2.0-edtFTPnet/PRO-7.3.1.20
DEBUG [SSH2Connection] 26 Apr 2011 22:39:15.964 : Starting key exchange
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.966 : Sending SSH_MSG_KEXINIT
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.967 : key exchange method=diffie-hellman-group1-sha1,diffie-hellman-group14-sha1
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.968 : hostkey algorithms=ssh-dss,ssh-rsa
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.969 : ciphers=blowfish-cbc,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.969 : ciphers=blowfish-cbc,aes128-cbc,aes192-cbc,aes256-cbc,3des-cbc,aes128-ctr,aes192-ctr,aes256-ctr
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.970 : MACs=hmac-sha1,hmac-md5
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.970 : MACs=hmac-sha1,hmac-md5
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.970 : compression algorithms=none,zlib
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.970 : compression algorithms=none,zlib
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:15.973 : Sent SSH_MSG_KEXINIT
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:15.973 : Reading SSH_MSG_KEXINIT reply
DEBUG [SSH2Connection] 26 Apr 2011 22:39:15.974 : Waiting for packet
DEBUG [PlainSocket] 26 Apr 2011 22:39:16.020 : RepeatCallback received 288 bytes
DEBUG [SSH2Connection] 26 Apr 2011 22:39:16.024 : Packet arrived
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.027 : Processing SSH_MSG_KEXINIT reply
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.029 : Remote kex alg=diffie-hellman-group-exchange-sha1,diffie-hellman-group1-sha1
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.030 : Decided kex alg= DiffieHellmanGroup1Sha1
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.030 : Remote hostkey alg=ssh-rsa
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.030 : Decided hostkey alg= RSA
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.033 : Remote Cipher CS=aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.034 : Decided Cipher C->S= AES128
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.034 : Remote Cipher SC=aes128-cbc,3des-cbc,aes192-cbc,aes256-cbc
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.034 : Decided Cipher S->C= AES128
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.034 : Remote MAC CS=hmac-sha1,hmac-sha1-96
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.035 : Decided MAC C->S= HMACSHA1
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.035 : Remote MAC SC=hmac-sha1,hmac-sha1-96
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.035 : Decided MAC S->C= HMACSHA1
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.035 : Remote Comp CS=none,zlib
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.036 : Decided Comp C->S=None
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.036 : Remote Comp SC=none,zlib
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.036 : Decided Comp S->C=None
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.036 : first_kex_packet_follows=False
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.036 : Processed SSH_MSG_KEXINIT reply
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.037 : Sending SSH_MSG_KEXDH_INIT
DEBUG [AbstractKeyExchanger] 26 Apr 2011 22:39:16.042 : DH_PRIME_GROUP1
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.076 : Sent SSH_MSG_KEXDH_INIT
DEBUG [ClientKeyExchanger] 26 Apr 2011 22:39:16.077 : Reading SSH_MSG_KEXDH_INIT reply
DEBUG [SSH2Connection] 26 Apr 2011 22:39:16.077 : Waiting for packet
DEBUG [PlainSocket] 26 Apr 2011 22:39:16.144 : RepeatCallback received 464 bytes
DEB