Provide the full path in FtpItem and SftpItem objects
If you call GetList("/Some/Path/Here/.txt"), the resultant list will contain the file names that match *.txt from the /Some/Path/Here path but, the full path to the file is not included. It can then be difficult to get those files, I have to save and parse the parameter passed to GetList and I have to know how to combine it with a file name. This gets harder when there are multiple operating systems. OpenVMS could be DISK:[Some.Path.Here].txt
It would be better we we could get the full path as supplied by the operating system.
This feature cannot be implemented. See the reasons in our comment below the feature request.
-
AdminRebex (Admin, Rebex) commented
FtpItem or SftpItem objects provide full path, if returned by the GetItems method, but they do not provide the full path, if not returned by the GetList method. There are several reasons we are not going to change this behaviour:
- The GetList is a lightweight method for simply getting items from a directory, most typically for all items from the current directory. It does not even determine the current directory name and so it cannot return a full path. Thanks to this, the GetList method can reliably work even on non-Unix-like file systems (like OpenVMS).
- Note that calling the GetList method with an argument like GetList(“/Some/Path/*.txt”) is not reliable when using FTP protocol. Only some FTP servers support this format, other servers would return nothing or report an error.
- The GetItems method works with a full path, but this method is reliable only on Unix-like file systems (with an uniform directory separator ‘/’). On other file systems the GetItems method may not work at all.
- Basically, there is no reliable way for determine correct full path. If you are going to connect to various FTP servers (and some of them may have a non-Unix-like filesystem), we suggest to design the application to work with the current directory only and not to use paths at all (use only file names received by the GetList method).Conclusion: If you need a full path in the FtpItem or SftpItem objects, use the GetItems method but it won’t work on non-Unix-like file systems. For non-Unix-like filesystems use the GetList method and construct the full path in your code.