FluentFTP icon indicating copy to clipboard operation
FluentFTP copied to clipboard

GetObjectInfo requires SetWorkingDirectory when retrieving info about a subfolder

Open JosHuybrighs opened this issue 3 years ago • 2 comments

FTP OS: Linux

FTP Server: Synology

Computer OS: Windows

FluentFTP Version: 34.02

When using GetObjectInfo(pathName) with pathname set to "user\test" or "\user\test", where 'user' is at the root of the server, no item is returned. FtpTrace reports:

Command:  MLST user\test
Response: 550 user\test can't be listed

What works is:

var dirPath = Path.GetDirectoryName(pathName);
var dirName = Path.GetFileName(pathName);
_ftpClient.SetWorkingDirectory(dirPath);
_dirItem = _ftpClient.GetObjectInfo(dirName);

Is this a bug or is it supposed to work this way?

Logs :

None.

JosHuybrighs avatar Aug 25 '21 07:08 JosHuybrighs

With all methods, providing a relative path (path that does NOT start with \) will assume it works in the current directory. Relative paths are entirely subject to your FTP server. Try absolute paths like \user\test instead.

robinrodricks avatar Aug 27 '21 12:08 robinrodricks

I will reexamine this.

robinrodricks avatar Aug 28 '21 09:08 robinrodricks

Relative paths are entirely subject to your FTP server

This is the key statement.

Command:  MLST user\test
Response: 550 user\test can't be listed

It is the server that is rejecting the list command in that syntax. Other server types might accept it and understand it.

Processing relative paths needs some more code than just supporting absolute paths. Small footprint server might not implement this correctly or might not implement it at all.

Unless there is protest, I am closing this to clean up the issues.

FanDjango avatar Feb 21 '23 20:02 FanDjango