Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

HateCrew

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.
martin

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.
HateCrew

Re: Can't Upload without subdirectories

As requested
I also added the logging.txt from WinSCP
martin

Re: Can't Upload without subdirectories

@HateCrew: As before, post a log file, please.
HateCrew

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.
martin

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/";
HateCrew

Re: Can't Upload without subdirectories

Hi Martin, as wished I attached a fresh new logfile.
martin

Re: Can't Upload without subdirectories

@HateCrew: The *.rck | */ looks good. If it does not work, please post session log file.
HateCrew

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.
martin

Re: Session.PutFiles - non recursive SFTP

put -filemask="|*/" *


I.e.: | to start exclude mask and */ to match (=exclude) all directories.
See https://winscp.net/eng/docs/file_mask

This is for the latest version of WinSCP.
John Thomas

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!