2

I tried below with no success -

string mask = "Report01|*[A-Z]" +"*.txt"; //This line fails to select files which contains only digits
TransferOperationResult transferResult;
transferResult = session.getFiles("RemoteServerPath" +mask,"DestinationServerPath",false,transferOptions);

I'm trying to exclude all reports which contains letters after digits.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992
Omkar Godse
  • 81
  • 1
  • 8

1 Answers1

1

This is not possible using WinSCP file mask syntax.

But you can easily:

Something like this:

var files = session.ListDirectory("/remote/path").Files;
files = files.Where(_ => Regex.Match(_.Name, "^[0-9]+\.txt$"));
foreach (var file in files)
{
    session.GetFileToDirectory(file.FullName, @"C:\local\path");
}
Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992