Topic "File mask in EnumerateRemoteFiles"

Author Message
Silviu Preda

Guest


Hi,

I have the following use case: I need to pick up all .pdf files from a FTP location root folder, but I need to exclude one folder, called Refference.
Code:
Code:
IEnumerable<RemoteFileInfo> directoryInfo = session.EnumerateRemoteFiles("/", "*.pdf |*/Reference/", EnumerationOptions.AllDirectories);


My mask is not ok, because now it excludes all files.

Testing:
Code:
directoryInfo.ToList().ForEach(di =>
                {
                    Logger.Information(di.FullName);
                });


When running without the
Code:
|*/Reference/
part, i get all the files, correctly, but when I add it, nothing is listed. How should I format my mask?

Thank you.

Silviu
Advertisements
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
What does you mean by "pick up"?

Do you want to download all PDF files from all folders except for Reference?

Code:
TransferOptions transferOptions = new TransferOptions();
transferOptions.FileMask = "*.pdf | Reference/";
session.GetFiles("/*", @"C:\local\path\*", false, transferOptions).Check();
Silviu Preda

Guest


Thank you for that. Is that also valid for the
Code:
EnumerateRemoteFiles
method? Because that's really where I need it.

Thanks
martin
[View user's profile]
Site Admin
Joined: 2002-12-10
Posts: 26572
Location: Prague, Czechia
No it's not.

For EnumerateRemoteFiles, if you need to skip a folder, you either have to filter the results to exclude files in the folder. Or, if you actually need to skip that folder (because it's not accessible or it's time consuming to enumerate it), you will have to do your own custom enumeration. It's not difficult. Check the source code of the .NET assembly.
Silviu Preda

Guest


Thanks man, appreciate it, will investigate.
Advertisements

You can post new topics in this forum






Search

What is WinSCP?

It is award-winning SFTP client, SCP client, FTPS client and FTP client integrated into one software program for file transfer to FTP server or secure SFTP server. [More]

And it's free!

Donate

About donations

$9   $19   $49   $99

About donations

Recommend

WinSCP Privacy Policy

WinSCP License