Post a reply

Before posting, please read how to report bug or request support effectively.

Bug reports without an attached log file are usually useless.

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)


Topic review


Re: Multiple File Mask for WinSCP Session.EnumerateRemoteFiles

The Session.EnumerateRemoteFiles supports a single mask only. If you need to use multiple masks, you will have to enumerate all files and select those you want yourself in your code.

Multiple File Mask for WinSCP Session.EnumerateRemoteFiles

I am rebuilding the FTP part of a performance monitor application, should be able to upload any file with extensions
.csv .xlsx .xls
and when i try to customize this mask it returns 0 files, but if i select only one of them it works fine.
string FileMask = "*.csv; *.xlsx; *.xls";
var sessionOptions = new SessionOptions
    Protocol = Protocol.Sftp,
    HostName = ConfigurationManager.AppSettings["FtpHost"],
    UserName = ConfigurationManager.AppSettings["FtpUsr"],
    Password = ConfigurationManager.AppSettings["FtpPwd"],
    SshHostKeyFingerprint = ConfigurationManager.AppSettings["SshHostKeyFingerprint"]
using (Session session = new Session())
    List<string> files =
        session.EnumerateRemoteFiles("/", FileMask, EnumerationOptions.AllDirectories)
        .Select(fileInfo => fileInfo.FullName)
    Console.WriteLine($"Found {files.Count} files");