How I can list all files using Limilabs FTP library in a root folder for example ?
I would like verify if exist files in a folder before.
I tried this way?
using (Ftp client = new Ftp())
{
client.Connect("ftp.example.org");
client.AuthTLS();
client.Login("username", "password");
RemoteSearchOptions options = new RemoteSearchOptions("*.txt", true);
List<RemoteSearchItem> items = client.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;
}
client.Close();
}
Happen a error when execute line 11. follow the error : Cannot allocate local port.
but is very stranger, because I can do this:
using (Ftp client = new Ftp())
{
client.Connect("ftp.example.org");
client.AuthTLS();
client.Login("username", "password");
foreach (FtpItem item in client.GetList())
{
if (item.IsFolder == true)
Console.WriteLine("[{0}]", item.Name);
else
Console.WriteLine("{0}", item.Name);
}
client.Close();
}