It is known behavior.
The GetItems()
method uses the GetList()
method internally to achieve complex tasks such as recursive directory traversing.
The ListItemReceived
is fired from the GetList()
method, which does not know the context of the complex operation.
To fill the correct full path in the event we would pass the context to the GetList()
method. However, you can do the same easily like this:
var client = new Ftp();
client.Connect("test.rebex.net");
client.Login("demo", "password");
string basePath = "/pub/example/";
client.ListItemReceived += (s, e) =>
{
var fullPath = basePath + e.Item.Name;
Console.WriteLine("{0}", fullPath);
};
var items = client.GetItems(basePath + "*", TraversalMode.NonRecursive);
Since you are using GetItemsAsync()
method, you can even pass the original full path to the UserState
:
client.ListItemReceived += (s, e) =>
{
var fullPath = (string)e.UserState + e.Item.Name;
Console.WriteLine("{0}", fullPath);
};
string basePath = "/pub/example/";
var items = await client.GetItemsAsync(basePath + "*", TraversalMode.NonRecursive, basePath);