-1

I'm using WinSCP .net assembly to download some files off of a ftp server. I want to restrict the download to

  1. Only the top level directory, ie. no sub directories
  2. Only .csv files

To accomplish this I'm using the include/exclude file masks

TransferOptions transferOptions = new TransferOptions();
transferOptions.FileMask = "*.csv | */";

Now the exclude part of the search is working fine and it doesn't bring down any subdirectories but the include part doesn't work at all. It's not downloading any csv files in the root directory. Does anyone know what I'm missing here?

reggaemahn
  • 4,932
  • 5
  • 26
  • 53
  • 1) Show us the code that actually **uses** `transferOptions`. 2) Show us WinSCP session log file (`session.SessionLogPath`). – Martin Prikryl Jul 04 '18 at 09:25
  • @MartinPrikryl Unfortunately I don't have those anymore but in terms of the code, it was exactly same as in my answer except it used `TransferOperationResult` instead of `SynchronizationResult`. In terms of the log, I remember looking at it and what it was doing was basically it was fetching the correct files based on the include file mask but at the end there was an entry saying the folder itself is excluded so it wouldn't fetch anything. Sorry, that's the best information I can give now. – reggaemahn Jul 05 '18 at 04:12

1 Answers1

0

For anyone who ends up here, this never worked for me no matter what I tried.

I ended up using the SynchronizationResult api instead, to achieve the same result. The exact same wildcard worked without any problems with it

        TransferOptions transferOptions = new TransferOptions
            {
                TransferMode = TransferMode.Binary,
                FileMask = "*.csv|*/"
            };

            SynchronizationResult result =
                session.SynchronizeDirectories(SynchronizationMode.Local, localDirectoryPath, remoteDirectoryPath, false, options: transferOptions);

            result.Check();
reggaemahn
  • 4,932
  • 5
  • 26
  • 53