0 votes
by (120 points)

I'm trying to convert my sftp.GetFile to a single sftp.Download but am getting the following error: "Could not find source path ('/ITAPDB')."

In the debugger, I've observed the value of the source path, and it's: "\ITAPDB\*" which is believe is the correct format, but is not what the exception is throwing. The destination path is: "C:\AWCTSTempLocal\ITAPDB\"

When it goes through the sftp.GetFile, the path requested is: "\ITAPDB\COAOCT.zip", which is correct, and is in concert with the path used for the sftp.Download.

The code for the sftp.Download is:

rootPath = rootPath + "\\*";
sftp.Download(rootPath, localRootPath, TraversalMode.MatchFilesShallow);

Please advise as to possible conditions that could cause this.

Thank you

Applies to: Rebex SFTP

1 Answer

0 votes
by (70.4k points)

Your code seems to be correct.

The exception says that source directory (which is "/ITAPDB") doesn't exist (it doesn't refer to exact argument value). The SFTP server doesn't recognize backslashes, so they are transformed into ordinal slashes.

To tell more, please send us the Debug log for the both transfers to support@rebex.net or post it here. It can be done like this:

// create client
var sftp = new Sftp();

// assign logger
sftp.LogWriter = new Rebex.FileLogWriter(@"C:\logs\sftp.log", Rebex.LogLevel.Debug);

// connect and login

// prepare paths
string filename = "CO_AOC_T.zip";
string rootPath = "/ITAPDB";
string localRootPath = @"C:\AWCTSTempLocal\ITAPDB";

// get single file
sftp.GetFile(Path.Combine(rootPath, filename), Path.Combine(localRootPath, filename));

// get all files from rootPath (on first level)
sftp.Download(rootPath + "/*", localRootPath, TraversalMode.MatchFilesShallow);
by (120 points)
Thank you. I was able to look at the log and see that the variable for whatever reason had a \ in front of it. Stripped that out and it works fine.