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.

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

martin

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

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())
{
    session.Open(sessionOptions);
 
    List<string> files =
        session.EnumerateRemoteFiles("/", FileMask, EnumerationOptions.AllDirectories)
        .Select(fileInfo => fileInfo.FullName)
        .ToList();
 
    Console.WriteLine($"Found {files.Count} files");
}