Session.GetFile throws "Recursive calls not allowed"
Hi,
I'm using the WinSCP 5.18.2-beta Version and I want to download a file via SFTP protocol to stream.
For .NET Standard 2.0 as well as for .NET Framework I´m getting the same errors.
After calling
Than after calling
I have also tried to use
So I don´t know if there´s something wrong with my code or could it be something else?
Best, David
I'm using the WinSCP 5.18.2-beta Version and I want to download a file via SFTP protocol to stream.
For .NET Standard 2.0 as well as for .NET Framework I´m getting the same errors.
After calling
session.GetFile
the stream has errors you can see in the attached file StreamErrors.PNG
.
Than after calling
session.Close
the following exception is thrown:
The code I´m using is the following:Exception:
System.InvalidOperationException: 'Recursive calls not allowed'
Stack:
at WinSCP.Lock.Enter()
at WinSCP.Session.Dispose()
at ..DownloadFile(String remotePath) in ..\Sftp.cs:line 97
using (var session = new Session()) { var sessionOptions = this.InitializeSessionOptions(); session.Open(sessionOptions); session.DebugLogPath = @"c:\test\log.txt"; var remoteFile = session .ListDirectory(remotePath) .Files .Where(x => x.IsDirectory == false) .OrderByDescending(x => x.LastWriteTime) .FirstOrDefault(); if (remoteFile != null) { sftpFile.Name = remoteFile.Name; sftpFile.Content = session.GetFile(remoteFile.FullName); } session.Close(); }
session.GetFileToDirectory
and it works perfectly fine.
So I don´t know if there´s something wrong with my code or could it be something else?
Best, David