Skip to content

GetListing problem with a pathname containing whitespaces and a server only supporting LIST #755

@JosHuybrighs

Description

@JosHuybrighs

FTP OS: Windows

FTP Server: CompleteFTP

Computer OS: Windows 10

FluentFTP Version: 35.0.2

I am using FluentFTP as a client in the next update of my SyncFolder sync/backup app (available in Windows Store). When testing with various type of FTP servers I am getting an error with the CompleteFTP Manager server when using GetListing with a path that contains whitespaces, like: "/Home/user/My Music". The server returns no items and the log says: "550 Directory does not exist."
I tested with the command line ftp client in windows and found the following:

ls /Home/user/My Music gives error 550
ls "/Home/user/My Music" is OK

I tried various ways to overcome this, like:

GetListing($"\"{path}\""),
GetListing(path.Replace(' ', '+')),
etc.

None of those were successfull, so I think that something is missing here. I have seen the topic coming up in other issue discussions, but also there I didn't find anything pointing to a solution.

I could overcome this by first setting the working directory to the path of which I would get the list and then using GetListing with the NoPath option, like so:

if (!_workingDirectory.Equals(path))
{
    _ftpClient.SetWorkingDirectory(path);
    _workingDirectory = path;
}
var items = _ftpClient.GetListing(null, FtpListOption.AllFiles | FtpListOption.NoPath);

This successfully returns all files and folders in "/Home/user/My Music".

There still is however a small error: all returned items have a wrong FullName property. E.g. if there is a file music.mp3 then the FullName property is set to "/music.mp3" instead of "/Home/user/My Music/music.mp3". This I can solve myself in my code but might be an issue for others.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions