I receive approximately 150k files per day from an SFTP site. The files have to be archived in a folder on the SFTP after downloading. Iterating individual files in a loop after getting the RemoteDirectoryInfo is too slow for the volume. When the _session.FileTransferred event is fired, I call the _session.MoveFile to archive the file as they are downloaded. The error below is the stack trace.
_session.GetFiles(remoteFilePath + "/*.*", localFilePath, removeSource, _transferOptions);
Recursive calls not allowed
at WinSCP.Lock.Enter()
at WinSCP.CallstackAndLock..ctor(Logger logger, Lock alock)
at WinSCP.Logger.CreateCallstackAndLock()
at WinSCP.Session.MoveFile(String sourcePath, String targetPath)
I've a solution that works albeit temporarily whereby I create a second session just to move the files, but if the session is idle for too long even with the ReconnectTime set to TimeSpan.MaxValue, the remote server closes the connection. I've added the Session log and debug log option, but it hasn't been helpful since the app can't tell me the session has been closed until I try to archive a file.
Any help would be appreciated.