Using more than one connections is certainly not a good option. You should be using search method:
using (Ftp ftp = new Ftp())
{
ftp.Connect("ftp.example.com"); // or ConnectSSL
ftp.Login("user","password");
// RemoteSearchOptions options = new RemoteSearchOptions("*.txt", true);
RemoteSearchOptions options = new RemoteSearchOptions()
List<RemoteSearchItem> items = ftp.Search(options);
foreach (RemoteSearchItem item in items)
{
string remotePath = item.GetRemotePath(); // full path e.g.: folder/a.txt
string name = item.FtpItem.Name; // name e.g.: a.txt
bool isFolder = item.IsFolder;
}
ftp.Close();
}
You can download list of RemoteSearchItem instances from the FTP easily:
Directory.CreateDirectory("c:\\Downloads");
ftp.DownloadFiles("c:\\Downloads", items);
or you can use overloaded Download method to specify FTP search criteria in a single place:
using (Ftp ftp = new Ftp())
{
ftp.Connect("ftp.example.com"); // or ConnectSSL
Directory.CreateDirectory(@"c:\Downloads");
// RemoteSearchOptions options = new RemoteSearchOptions("*.txt", true);
RemoteSearchOptions options = new RemoteSearchOptions()
ftp.DownloadFiles(@"c:\Downloads", options);
ftp.Close();
}