I am trying to upload the contents of a folder (but not the sub-folders, which have backup files, archive files and errored files) to a server using the WinSCP .NET assembly. Is this even possible? If so, how do I do it?
Quick code clip of my existing piece:
// string mode ...
// Session sess ...
// TransferOperationResult res ...
TransferOptions tOpts = new TransferOptions();
tOpts.FileMask = c.SearchPattern;
tOpts.TransferMode = TransferMode.Binary;
tOpts.PreserveTimestamp = true;
SetMessage("Uploading files");
res = sess.PutFiles(Path.Combine(c.LocalPath, c.SearchPattern),
c.RemotePath,
c.DeleteAfterXFer,
tOpts);
Is there some way of saying something to the effect of:
tOpts.TopDirectoryOnly = true
?
Use file mask
|*/
to exclude all (sub-)directories.Use the
TransferOptions.FileMask
property to set the file mask.Specifically for your sample, do:
Also documented in WinSCP FAQ How do I transfer (or synchronize) directory non-recursively?