File mask in EnumerateRemoteFiles

Advertisement

Silviu Preda
Guest

File mask in EnumerateRemoteFiles

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:
IEnumerable<RemoteFileInfo> directoryInfo = session.EnumerateRemoteFiles("/", "*.pdf |*/Reference/", EnumerationOptions.AllDirectories);

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

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

When running without the
|*/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

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: File mask in EnumerateRemoteFiles

What does you mean by "pick up"?

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

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

Reply with quote

Silviu Preda
Guest

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

Thanks

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
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.

Reply with quote

Advertisement

Ajay
Guest

EnumerateRemoteFiles in Perl

Hi,
Would you know how the syntax would look like for EnumerateRemoteFiles in Perl.

My requirement here is to find out if the files with wildcard are available in remote server or not. However i am struggling to find the syntax for winscp perl module to achieve the same.

Constructed the following command without much luck.

my $files =$session->EnumerateRemoteFiles('/data/incoming', '*.txt','EnumerationOptions_None');

Your assistance would greatly help.

Thanks
Ajay

Reply with quote

martin
Site Admin
martin avatar
Joined:
Posts:
40,476
Location:
Prague, Czechia

Re: EnumerateRemoteFiles in Perl

Ajay wrote:

Would you know how the syntax would look like for EnumerateRemoteFiles in Perl.
You cannot use EnumerateRemoteFiles in Perl, as documented:
The method cannot be used via COM interface

Reply with quote

Advertisement

You can post new topics in this forum