I've seen a few posts from years ago, but I haven't seen anything recent. What am I missing? Connecting to a simple sFTP server with user/password auth, and I can list files in a directory. But when I try to check if a file exists, I receive the error that "The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established."
This did not happen in the previous version I was using, 10.1. It only happened once I moved to the latest version, 12.5.0.
sftp.Connect();
var remoteFiles = sftp.ListDirectory(dataDirectory);
foreach (FTPFile remoteFile in remoteFiles)
{
if (remoteFile.Dir)
continue;
// check if this file is already in another directory
string anotherName = OtherDirectoryName + remoteFile.Name;
if (sftp.Exists(anotherName )) <<<<<< problem here
EnterpriseDT.Net.Ftp.FTPException
HResult=0x80131600
Message=The FTP client has not yet connected to the server. The requested action cannot be performed until after a connection has been established.
Source=edtFTPnetPRO
StackTrace:
at EnterpriseDT.Net.Ftp.FTPClient.pE4vf83jcr(Boolean )
at EnterpriseDT.Net.Ftp.FTPClient.Exists(String remoteFile)
at EnterpriseDT.Net.Ftp.FTPConnection.Exists(String remoteFile)
The FTP component is setup with a username and password.
Protocol = FileTransferProtocol.SFTP,
ServerValidation = SecureFTPServerValidationType.None,
Log (I hope the relevant sections - I'm limited in what I can post)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.159 : User authentication successful
......
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 : Set transfer type = BINARY
DEBUG [FTPConnection] 18 Aug 2025 01:25:13.437 : Home directory is '/home/user'
DEBUG [FTPConnection] 18 Aug 2025 01:25:13.437 : GetFileInfos('/home/user/data_qa/')
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 : ResolveRemotePath('/home/user/data_qa/'); [cwd='/home/user']
DEBUG [SSHFTPClient] 18 Aug 2025 01:25:13.437 : Resolved to '/home/user/data_qa'
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.437 : Send : Name=SSH_FXP_REALPATH,Type=16,RequestID=2
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.437 : Transmit 46 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.437 : Remote window size decreased to 2097083
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.437 : Sent 84 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.437 : Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.484 : FTPConnection.12 RepeatCallback received 132 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.484 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.484 : FTPConnection.12 CreateMessage (bufferlength=100,offset=13,length=87,type=104)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 : FTPConnection.12 SSH_FXP_NAME: requestID=2, 1 files
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.484 : FTPConnection.12 AddMessage(2) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 : Reply : Name=SSH_FXP_NAME,Type=104,RequestID=2
DEBUG [SFTPSubsystem] 18 Aug 2025 01:25:13.484 : Opening directory /home/user/data_qa
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.484 : Send : Name=SSH_FXP_OPENDIR,Type=11,RequestID=3
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.484 : Transmit 46 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.484 : Remote window size decreased to 2097037
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.484 : Sent 84 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.484 : Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.531 : FTPConnection.12 RepeatCallback received 60 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.532 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.532 : FTPConnection.12 CreateMessage (bufferlength=26,offset=13,length=13,type=102)
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.532 : FTPConnection.12 AddMessage(3) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.532 : Reply : Name=SSH_FXP_HANDLE,Type=102,RequestID=3
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.532 : Send : Name=SSH_FXP_READDIR,Type=12,RequestID=4
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.532 : Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.532 : Remote window size decreased to 2097020
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.533 : Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.533 : Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.582 : FTPConnection.12 RepeatCallback received 7676 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.582 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.582 : FTPConnection.12 CreateMessage (bufferlength=7646,offset=13,length=7633,type=104)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 : FTPConnection.12 SSH_FXP_NAME: requestID=4, 39 files
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.582 : FTPConnection.12 AddMessage(4) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 : Reply : Name=SSH_FXP_NAME,Type=104,RequestID=4
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.582 : Send : Name=SSH_FXP_READDIR,Type=12,RequestID=5
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.582 : Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.582 : Remote window size decreased to 2097003
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.582 : Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.583 : Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.623 : FTPConnection.12 RepeatCallback received 76 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.623 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.623 : FTPConnection.12 CreateMessage (bufferlength=41,offset=13,length=28,type=101)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 : FTPConnection.12 ErrorCode|Status=1
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.623 : FTPConnection.12 AddMessage(5) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 : Reply : Name=SSH_FXP_STATUS,Type=101,RequestID=5
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.623 : Send : Name=SSH_FXP_CLOSE,Type=4,RequestID=6
DEBUG [SSH2Channel] 18 Aug 2025 01:25:13.623 : Transmit 17 bytes
DEBUG [ChannelDataWindow] 18 Aug 2025 01:25:13.623 : Remote window size decreased to 2096986
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.623 : Sent 60 bytes (NoDelay=True, SendBufferSize=65536, ReceiveBufferSize=65536)
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.623 : Packet written to socket
DEBUG [PlainSocket] 18 Aug 2025 01:25:13.667 : FTPConnection.12 RepeatCallback received 68 bytes
DEBUG [SSH2Connection] 18 Aug 2025 01:25:13.667 : FTPConnection.12 ProcessPacket pt=SSH_MSG_CHANNEL_DATA
DEBUG [SFTPMessageFactory] 18 Aug 2025 01:25:13.667 : FTPConnection.12 CreateMessage (bufferlength=37,offset=13,length=24,type=101)
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.667 : FTPConnection.12 ErrorCode|Status=0
DEBUG [SFTPMessageStore] 18 Aug 2025 01:25:13.667 : FTPConnection.12 AddMessage(6) - added to store
DEBUG [SFTPMessage] 18 Aug 2025 01:25:13.667 : Reply : Name=SSH_FXP_STATUS,Type=101,RequestID=6
DEBUG [FTPConnection] 18 Aug 2025 01:25:15.785 : Exists(/home/user/data_qa/processed/checkfile.zip)