Currently, I'm using the Ftp.GetItems()
extension method to get all items of a given path.
I'm looping the result item collection until I find the first item for which IsDirectory
is true.
In pseudo-code:
public bool HasChildFolders(string path)
{
var items = _ftp.GetItems(path);
foreach ( var item in items )
{
if ( item.IsDirectory ) return true;
}
return false;
}
Unfortunately, if the given path
contains lots of child folders this takes ages to complete (I have folders with several 10k child folders).
So I'm searching for a faster way to check whether a folder contains at least one child folder.
My question:
How to quickly check whether a folder contains at least one child folder, even for a huge number of child folders?