2

I am implementing FluentFTP in my application but I cannot list the contents of a folder on the FTP server.
When I use an ftp application like FileZilla I can clearly see that in my user directory there are 2 folders :

enter image description here

The Out folder contains some files, but when I retrieve a listing using FluentFTP I always get these 2 folders, not the contents of the Out folder.

This is the code I am using

FtpClient client = new FtpClient();
client.Host = _ftpDefinition.Host;
client.Port = _ftpDefinition.Port;
client.Credentials = new NetworkCredential(_ftpDefinition.UserName, _ftpDefinition.PassWord);
client.Connect();

foreach (FtpListItem item in ftpClient.GetListing(remoteDir))
{
    if (item.Type == FtpFileSystemObjectType.File)
    {
         _remoteFiles.Add(item.Name); // add the filename to a List<string>
    }
}

I tried these combinations for the variable remoteDir :

Out
/Out
Out/
/Out/

none of them is working, the GetListing always retuns the 2 folders in stead of the contents of the Out folder.

What am I doing wrong ?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
GuidoG
  • 11,359
  • 6
  • 44
  • 79

1 Answers1

2

According to their docs

You should be able to use

GetWorkingDirectory() - Gets the full path of the current working directory.

SetWorkingDirectory() - Sets the full path of the current working directory.

Such as

FtpClient.SetWorkingDirectory("/Out");

BugFinder
  • 17,474
  • 4
  • 36
  • 51
  • That seems to be working, can you think of any reason why the GetListing() does not works with the same /Out ? – GuidoG Jan 04 '17 at 14:33
  • Never used fluentftp ever :p sorry. it maybe its case sensitive and despite showing with caps, its lower case.. it would be one of those things Id want to see in raw ftp client (not filezilla) and the server end to tell you maybe more why (the server would have logs of whats sent) – BugFinder Jan 04 '17 at 14:36
  • For some reason this solution stopped working. When I do GetWorkingDirectory after the SetWorkingDirectory it returns /Out like it did before, but for some reason the GetListing() now always retuns nothing even when there are files there. I am starting to think that FluentFTP is not that good after all and that I need to start looking for another library again – GuidoG Jan 04 '17 at 15:47
  • Does sound dodgy. Is listing allowed in the out folder? Are there maybe settings like passive ftp that filezilla turns on by default you have not? – BugFinder Jan 05 '17 at 01:13
  • I switched to another library, edtFTPFree and this one works like a charm right from the beginning. Thanks for you time and effort – GuidoG Jan 05 '17 at 15:57