Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
2.6k views
in .NET FTP by (1.4k points)
Is there any way to filter the ftpLocalFileList in edtFtpPro to exclude thumbs.db and allow all other files to be visible?

11 Answers

0 votes
by (161k points)
Have you tried using the CustomFilter property?
0 votes
by (1.4k points)
Have you tried using the CustomFilter property?


No wasn't quite sure how to do that with the localftpdirectory. Would it be similar/same as how we can add customer filters to multiuploads, etc? If so I have done that.

--/Greg
0 votes
by (1.4k points)
Have you tried using the CustomFilter property?


I am using 8.6.4.....
I did not see a CustomFilter property, but I assume you meant WilcardFilter? I am able to set a single pattern like *.DAT and that works, however I am unable to set for m ore than one. I would like to be able to set like "*.dat,*.xls,*.csv") and exclude all others or exclude one file type and include all others. I do not see a way to filter out just the thumbs.db file and include all others
0 votes
by (161k points)
There's a CustomFilter property in FTPFileList, the base class.
0 votes
by (1.4k points)
There's a CustomFilter property in FTPFileList, the base class.

OK. Found it. Still cannot figure out how to use it with the local file list. When i upload/download, i call a delegate to filter which works.

This is what I am trying but not working..

this part dows not work
foreach (FTPFile item in FtpLocalFileList1) {
FtpLocalFileList1.CustomFilter = new FileFilter(IsFileDb(item));
}

and

private bool IsFileDb(FTPFile file)
{
bool filterFile = false;

if (file.Name.ToUpper.Contains(".DB")) {
filterFile = false;
//return all files except .db
} else {
filterFile = true;
}

return filterFile;
}

Are there any examples of using a customFilter or snippets or any help to assist in this?

Thanks
0 votes
by (161k points)
You only need to assign the property once, when you create the list.
0 votes
by (1.4k points)
You only need to assign the property once, when you create the list.


OK, there are no examples on how to do that, that I can find anywhere -- set up a customer filter for a local file list. I do not know how to assign this property with a filefilter that allows all file types except a extension of .db. I looked at your help file and could not figure out how to create a filefilter using the ftplocalfilelist.customfilter. The filefilter takes a ftpfile as an arg, but do not see how that is used with local file list where i can exclude certain file types. I thought I could iterate the list, but you said no and to assign when created. Now I am confused as to what to do. With upload/downloads that is pretty straightforward. Can you provide an example or a snippet of what I need to do please. Thanks.
0 votes
by (161k points)
Your code is basically correct, but you just need to set the property once.

private void ftpLocalFileList1_Load(object sender, EventArgs e)
    {
        ftpLocalFileList1.CustomFilter = new FileFilter(IsFileDb);
        ftpLocalFileList1.RefreshFileList();
    }
0 votes
by (1.4k points)
Your code is basically correct, but you just need to set the property once.

private void ftpLocalFileList1_Load(object sender, EventArgs e)
    {
        ftpLocalFileList1.CustomFilter = new FileFilter(IsFileDb);
        ftpLocalFileList1.RefreshFileList();
    }


Thanks. Here is my isFileDB which shows no files if one is a thumbs.db file. Doesn't seem to work if any is returned as false

private bool IsFileDb()
{

bool result = true;
object fileEntries = Directory.GetFiles(ftpList.LocalDirectory);

foreach (string fileItem in fileEntries) {
if ((Path.GetExtension(fileItem).ToUpper().Contains(".DB"))) {
result = False
} else {
result = true;
}
}
return result;
}
0 votes
by (161k points)
No, just use your previous IsFileDB code, i.e. private bool IsFileDb(FTPFile file).

Categories

...