0 votes
by (160 points)
edited

Rebex is adding an unwanted "C:\" to my local path and filename. The local path is a network share so the presence of this C:\ is causing the operation to fail. I don't see a method signature that tells it not to do this. Can anyone please help?

Here is the method call in C# :

System.Threading.Tasks.Task<long> operation = sftp.GetFileAsync(RemotePathAndFilename, LocalPathAndFilename);

LocalPathAndFilename is something like:

\\\storage\inetpub\wwwproduction\transfers\download1121.zip

When I walk through with the debugger, or run in production and have it email the exception to me, it is clear that Rebex is prefixing the C:\ to LocalPathAndFilename. So it turns into:

C:\\\storage\inetpub\wwwproduction\transfers\download1121.zip

The InnerException, which is correct since there is no such path, is:

Local path is not a file path or a part of the path doesn't exists. at Rebex.MDB.N(String A, FileMode B, FileAccess C, FileShare D, LDB E) at Rebex.Net.Sftp.WAB(FileMode A, BEB B, String C, String D, Int64 E, Int64 H, Int64 I, WCB J) at Rebex.Net.Sftp.AQ(Object A, Enum B, Object[] C) at Rebex.UDB.Z(Object A)

Applies to: Rebex SFTP

2 Answers

0 votes
by (58.9k points)
edited

Rebex definitely should not add "C:\" prefix to local path. In fact with the GetFile method we take the local file path "as is" and just feed it to the new FileStream instance to open the local file.

Please produce a log of communication and either post the log here or send it to support@rebex.net. We will be able to look into this issue then!

0 votes
by (160 points)
edited

Thanks for your response Tomas. Here is the output of the log file. Please let me know if you can provide any further help.

2014-05-20 13:00:06.599 Opening log file.
2014-05-20 13:00:06.599 Using FileLogWriter version 2.0.5171.0.
2014-05-20 13:00:06.631 INFO Sftp(3)[15] Info: Connecting to sftp1.capitalhealth.ca:22 using Sftp 3.0.5171.0.
2014-05-20 13:00:06.724 DEBUG Sftp(3)[15] SSH: Server is 'SSH-2.0-1.36_sshlib GlobalSCAPE'.
2014-05-20 13:00:06.724 INFO Sftp(3)[15] SSH: Negotiation started.
2014-05-20 13:00:06.740 DEBUG Sftp(3)[15] SSH: Group exchange.
2014-05-20 13:00:06.787 DEBUG Sftp(3)[15] SSH: Negotiating key.
2014-05-20 13:00:06.881 DEBUG Sftp(3)[15] SSH: Validating signature.
2014-05-20 13:00:06.928 INFO Sftp(3)[15] SSH: Negotiation finished.
2014-05-20 13:00:06.928 INFO Sftp(3)[15] Info: Server: SSH-2.0-1.36_sshlib GlobalSCAPE
2014-05-20 13:00:06.928 INFO Sftp(3)[15] Info: Fingerprint: e7:fc:5e:28:ad:4c:c1:f8:b2:cc:6b:bd:8d:7b:f1:86
2014-05-20 13:00:06.943 INFO Sftp(3)[15] Info: Cipher info: SSH 2.0, DiffieHellmanGroupExchangeSHA1, DSS, aes256-cbc/aes256-cbc, hmac-sha1/hmac-sha1
2014-05-20 13:00:07.006 INFO Sftp(3)[15] SSH: Received banner: Welcome to Alberta Health Services SFTP site
2014-05-20 13:00:07.053 DEBUG Sftp(3)[15] SSH: Allowed authentication methods: password, keyboard-interactive.
2014-05-20 13:00:07.053 DEBUG Sftp(3)[15] SSH: Trying password authentication for 'ICAROL'.
2014-05-20 13:00:07.099 DEBUG Sftp(3)[15] SSH: Authentication successful.
2014-05-20 13:00:07.131 DEBUG Sftp(3)[15] SSH: Requesting subsystem 'sftp'.
2014-05-20 13:00:07.178 INFO Sftp(3)[15] Command: SSH_FXP_INIT (4)
2014-05-20 13:00:07.224 INFO Sftp(3)[15] Response: SSH_FXP_VERSION (3, 0 extensions)
2014-05-20 13:00:07.224 INFO Sftp(3)[15] Info: Using SFTP v3 on a Windows-like platform.
2014-05-20 13:00:07.224 INFO Sftp(3)[15] Command: SSH_FXP_REALPATH (1, '.')
2014-05-20 13:00:07.287 INFO Sftp(3)[15] Response: SSH_FXP_NAME (1, 1 item)
2014-05-20 13:00:07.287 INFO Sftp(3)[15] Info: Current directory is '/'.
2014-05-20 13:00:07.506 ERROR Sftp(3)[14] Info: Rebex.Net.SftpException: Local path is not a file path or a part of the path doesn't exists. ---> System.IO.DirectoryNotFoundException: Could not find a part of the path 'C:\storage2\inetpub\icarolwebapp\secure\Resources\Imports\From20140516Through20140517UpdateExport.xml.zip'.
   at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
   at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, Int32 rights, Boolean useRights, FileShare share, Int32 bufferSize, FileOptions options, SECURITY_ATTRIBUTES secAttrs, String msgPath, Boolean bFromProxy, Boolean useLongPath, Boolean checkHost)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, String msgPath, Boolean bFromProxy)
   at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share)
   at Rebex.MDB.N(String A, FileMode B, FileAccess C, FileShare D, LDB E)
   --- End of inner exception stack trace ---
   at Rebex.MDB.N(String A, FileMode B, FileAccess C, FileShare D, LDB E)
   at Rebex.Net.Sftp.WAB(FileMode A, BEB B, String C, String D, Int64 E, Int64 H, Int64 I, WCB J)
by (160 points)
edited

sorry about the formatting!

by (18.1k points)
edited

That is really strange. Did you tried to create the same local file using standard .NET system library?

System.IO.File.CreateText(LocalPathAndFilename)
Does it work without such exception?

by (160 points)
edited

Thanks for responding. It turned out to be my bug. I was removing the leading double-slash to indicate network share leaving only a single slash. .Net or the OS was then seeing that and applying the drive letter of the local system. Sorry for wasting your time and thanks for trying to help.

...