Session.PutFiles - non recursive SFTP

Advertisement

John Thomas
Joined:
Posts:
2
Location:
Malaysia

Session.PutFiles - non recursive SFTP

Hi,

I need to do an SFTP transfer which is non-recursive.
I tried using Filemasks but still not able to do a non-recursive transfer.
Currently all the files and subdirectories in the source location are transferred over. I need the sub directories to remain intact.
How do I proceed further?

Thanks a bunch!

Reply with quote

Advertisement

HateCrew
Guest

Can't Upload without subdirectories

Hi All
We face the same issue by upload some files but without subdirectories.
var localPath = "C:\Temp\WinSCP\";
var ftpPath = "sftp.winscp.com/upload/test";
//var fileMask = $@"*.rck | */";
var fileMask = $@"*.* | */";
var transferResult = session.PutFiles(localPath, ftpPath, false, new TransferOptions() { OverwriteMode = OverwriteMode.Overwrite, TransferMode = TransferMode.Binary, FileMask = fileMask });
We have to upload all *.rck Files but without any subdirectories.
Tested with Version 5.19.6 without any success.

Reply with quote

HateCrew
Guest

Re: Can't Upload without subdirectories

Hi Martin, as wished I attached a fresh new logfile.
  • session_anonym.txt (20.25 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,441
Location:
Prague, Czechia

Re: Can't Upload without subdirectories

Ok, so you do not have a problem with subdirectories, right? The problem is that nothing is uploaded.
The logs file tells, what's wrong:
Selecting files using a path ending with slash is ambiguous. Remove the slash to select the folder. Append * mask to select all files in the folder.
See also https://winscp.net/eng/docs/library_session_putfiles#parameters
I assume you want:
var localPath = "C:\Temp\WinSCP\*";
var ftpPath = "sftp.winscp.com/upload/test/";

Reply with quote

HateCrew
Guest

Re: Can't Upload without subdirectories

Hi Martin
We checked with your input without success.
The Folder in the root directory and all files in it with the same ending are uploaded.
var localPath = "C:\Temp\WinSCP\*";
var ftpPath = "sftp.winscp.com/upload/test/";
We only want to upload the root directory with the topdirectory files.
Without the Folder and without files in the subfolders, also not if they match filepattern.
Thanks for help.

Reply with quote

HateCrew
Guest

Re: Can't Upload without subdirectories

As requested
I also added the logging.txt from WinSCP
  • session.txt (486.43 KB, Private file)
  • logging.txt (858.18 KB, Private file)

Reply with quote

Advertisement

martin
Site Admin
martin avatar

Re: Can't Upload without subdirectories

Where's the | */? I do not see you using it in the log. The file mask is only *.rck. You have to use both the | */ and the correct paths.

Reply with quote

HateCrew
Guest

Re: Can't Upload without subdirectories

You are totally right, we missed to add it for testing again.
We also got it working now with following changes:
  • localfilepath has to end with \*
  • ftp path has to end with /
  • filepattern is .rck | */
Thanks for the help, don't know why it not worked earlier, because we had this as testcase.

Reply with quote

Advertisement

You can post new topics in this forum