Post a reply

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

Vara04

If I can help :

This is how it can be done :

Regexp construction pattern : see PJ

Loop on file return by ListDirectory with a new parameter pattern

RemoteDirectoryInfo v_RemoteDirectoryInfo = session.ListDirectory(path);
Regex v_Regex = FTPClientBeanCommandFTP.FindFilesPatternToRegex.Convert(pattern);
List<RemoteFileInfo> v_ListFile = new List<RemoteFileInfo>();
foreach (RemoteFileInfo v_RemoteFileInfo in v_RemoteDirectoryInfo.Files)
{
   if ((!v_RemoteFileInfo.IsDirectory)
      && (v_Regex.IsMatch(v_RemoteFileInfo.Name)))
   {
      v_ListFile.Add(v_RemoteFileInfo);
   }
}
 
// This can not be done because ".Files" is read only
v_RemoteDirectoryInfo.Files.Clear();
foreach (RemoteFileInfo v_RemoteFileInfo in v_ListFile)
{
   v_RemoteDirectoryInfo.Files.Add(v_RemoteFileInfo);
}


So it can be call like this :
RemoteDirectoryInfo v_RemoteDirectoryInfo = session.ListDirectory("/TestFTP", "*.CSV");
Vara04

Ok thanks
martin

Re: ListDirectory with file pattern

It is not supported and most protocols do not support filtering listing on the server side anyway.
So do it yourself.
Vara04

ListDirectory with file pattern

Hello,

How can I list on remote FTP server : /mydir/*.csv
It works fine with /mydir but not with file pattern :-\

Any solution ?

ok I can list all files and after filter them but if there is a better solution ;-)