SSH.NET icon indicating copy to clipboard operation
SSH.NET copied to clipboard

ReadAllLines and WriteAllLines are not working.

Open amolsamgir1 opened this issue 9 years ago • 8 comments

Client has WS_FTP from where we are trying to read/ write but ReadAllLines and WriteAllLines are not working, we are getting below exception,

Renci.SshNet.Common.SshException was unhandled HResult=-2146233088 Message=Folder not found: E:\IPSHOME\SHAREDFOLDERS\EXCHANGE\OUT\test.txt Source=Renci.SshNet StackTrace: at Renci.SshNet.Sftp.SftpSession.RequestFStat(Byte[] handle, Boolean nullOnError) at Renci.SshNet.Sftp.SftpFileStream..ctor(SftpSession session, String path, FileMode mode, FileAccess access, Int32 bufferSize, Boolean useAsync) at Renci.SshNet.Sftp.SftpFileStream..ctor(SftpSession session, String path, FileMode mode, FileAccess access) at Renci.SshNet.SftpClient.OpenRead(String path) at Renci.SshNet.SftpClient.ReadAllLines(String path, Encoding encoding) at Renci.SshNet.SftpClient.ReadAllLines(String path) at SFTP_Test.SFTPHelper.GetFilesInLines(String targetFolder, String targetFileNameStartsWith, String targetFileNameEndsWith, String correlationID) in c:\Users\c-amol.samgir\Documents\Visual Studio 2012\Projects\SFTP_Test\SFTP_Test\SFTPHelper.cs:line 66 at SFTP_Test.Program.Main(String[] args) in c:\Users\c-amol.samgir\Documents\Visual Studio 2012\Projects\SFTP_Test\SFTP_Test\Program.cs:line 18 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart() InnerException:

We are passing /EXCHANGE/OUT as path, It list out all the files of this directory.

Note : UploadFile and DownloadFile calls are working fine.

amolsamgir1 avatar Jun 07 '17 07:06 amolsamgir1

Please try using the latest beta (2016.1.0-beta2), and let me know if it works for you.

drieseng avatar Aug 16 '17 19:08 drieseng

Have you been able to try 2016.1.0-beta2?

drieseng avatar Sep 17 '17 16:09 drieseng

Hi, @drieseng, may I know the root cause of this problem? We hit the similar error with the following call stack (our code is directly calling SftpClient.OpenRead to get a SftpFileStream):

Type=Renci.SshNet.Common.SshException,Message=Folder not found: \*****\test.csv,Source=Renci.SshNet,StackTrace=
at Renci.SshNet.Sftp.SftpSession.RequestFStat(Byte[] handle) at Renci.SshNet.Sftp.SftpFileStream..ctor(ISftpSession session, String path, FileMode mode, FileAccess access, Int32 bufferSize, Boolean useAsync) at Renci.SshNet.Sftp.SftpFileStream..ctor(ISftpSession session, String path, FileMode mode, FileAccess access, Int32 bufferSize) at Renci.SshNet.SftpClient.OpenRead(String path) at Renci.SshNet.Sftp.SftpSession.RequestFStat(Byte[] handle) at Renci.SshNet.Sftp.SftpFileStream..ctor(ISftpSession session, String path, FileMode mode, FileAccess access, Int32 bufferSize, Boolean useAsync) at Renci.SshNet.Sftp.SftpFileStream..ctor(ISftpSession session, String path, FileMode mode, FileAccess access, Int32 bufferSize) at Renci.SshNet.SftpClient.OpenRead(String path)

And will we get the issue resolved after update to 2016.1.0-beta2? Thanks.

bowen5 avatar Sep 26 '17 07:09 bowen5

@iRainbow5 We now only invoke RequestFStat(Byte[]) (which sends a SSH_FXP_FSTAT request) in case of an append, so you should no longer get this exception.

drieseng avatar Sep 28 '17 18:09 drieseng

@iRainbow5 @amolsamgir1 What SSH server (and version) are you both using?

drieseng avatar Sep 28 '17 19:09 drieseng

Thank you @drieseng, I'm using WS_FTP.

bowen5 avatar Oct 09 '17 06:10 bowen5

@iRainbow5 @amolsamgir1 Can you still reproduce this issue with version 2016.1.0?

drieseng avatar Oct 26 '17 19:10 drieseng

No feedback.

drieseng avatar Jun 27 '20 14:06 drieseng