Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5.1k views
in .NET FTP by (200 points)
Using edtFTPnetPRO 4.1 and the ExFTPConnection object, I am trying to download a directory that has subdirectories and skip some of those subdirectories based on their names. My call to DownloadMultiple looks like this:

ftp.DownloadMultiple(topLeveDir, txtVSSCopy.Text.Replace(txtURLDescription.Text, ""), new FileFilter(IgnoreFilesGetFirst), true);


and the file filter looks like this:

    bool IgnoreFilesGetFirst(FTPFile file)
    {
        bool getFile = true;

        if (file.Dir == true)
        {
            foreach (string dir in dirsToIgnore)
            {
                if (file.Name == dir)
                {
                    getFile = false;
                    break;
                }
            }
        }
        else
        {
            foreach (string ext in extsToIgnore)
            {
                if (file.Name.ToUpper().EndsWith(ext.ToUpper()))
                {
                    getFile = false;
                    break;
                }
            }
        }

        return getFile;
    }


The problem is that, as far as I can tell, file.Dir is never true so that part of the if statement never gets executed. Even if I put "return false;" right after "if (file.Dir == true)" all the subdirectories still download even though (I think) none of them should. Am I doing something wrong, or am I misinterpreting how this is supposed to work, or is there a bug?

Thanks,
Jeff Metzner
DSG

8 Answers

0 votes
by (162k points)
Looking at the source code, I can see why it isn't working - it only applies the filter to files, and traverses all directories irrespective of name. If this is a big issue for you, we can make a change to filter out directories too.
0 votes
by (200 points)
Bruce:

Thanks for looking into it. I do need some way to skip certain subdirectories. I could do it by name, but it sounds like that won't work with the current code either.

Ideally, since the filter function is being passed FTPFile objects for each file it should be passed one for each directory too (with the Dir property set to true) and it should skip the entire directory if the filter function returns false. If that's a change you're willing to make, that would be really helpful.

Thanks,
Jeff Metzner
0 votes
by (162k points)
Yes, this sounds like a sensible & useful change. We'll get a fix to you ASAP to try out - probably on Monday.
0 votes
by (200 points)
Thanks, Bruce. One of my colleagues will follow up in this thread on Monday, because this is my last day at this job.
0 votes
by (200 points)
Following up to see if the update to the code is ready for release

thanks
Rick Shiffer
DSG
0 votes
by (162k points)
Sorry, a tad delayed. Please send an email to support@enterprisedt.com and we'll send you a link so you can download the patched DLL.
0 votes
by (200 points)
I have not received an email link from Support for the update for Filter directories using DownloadMultiple
0 votes
by (162k points)
This is now officially released in edtFTPnet/PRO 5.0.1, which is out now.

Categories

...