0 votes
by (130 points)
edited

Hello. I am trying to figure out how to get a path to my FtpItem object without hard coding it into my system.

When I try to call the path with ftpItem.Path, it just returns the name of the file.

The documentation on this states that: "(Path)Gets the path of the file or directory. It can be relative or absolute path depending on the way of use. "

I did some research and could not figure out what was meant by "depending on the way of use."

So for instance if a file named "person" is located at /missions/Run/person , I want to return just /missions/Run/ (/missions/Run/person works too)

Right now it just returns "person"

Thank you in advance!

Applies to: Rebex FTP/SSL

2 Answers

+1 vote
by (64.5k points)
edited

You probably retrieved the FtpItem by the GetList() method. This method represents the MLSD (or LIST) command which doesn't contain absolute path information. This is simple and fast method intended to retrieve items in the current remote directory.

To retrieve advanced information about items, use the complex GetItems() method like this:

var list = client.GetItems("*", TraversalMode.NonRecursive);

If you want to retrieve only files, use it like this:

var list = client.GetItems("*", TraversalMode.MatchFilesShallow);

Alternatively, you can still use the GetList() method and combine client.GetCurrentDirectory() with FtpItem.Name.

by (130 points)
edited

Thank you! That's exactly what I was doing wrong.

0 votes
by (140 points)

If you call the GetList() method the you can get the list.This list contain list will contain the file names that match *.txt and it is not include the full path file name.Then you are pass the parameter in to the above method and connect to the file name.You can get FTP path related research paper hints from the different source.

...