0 votes
by (270 points)

Hello
I am using Rebex.FTP(v. 4.0.6249.0) library for my FTP client and I have troubles with GetItems method's traversalMode parameter. If it is set to NonRecursive, only the current directory is returned and not the files inside. If I use MatchFilesShallow or MatchFilesDeep, I get "Ambiguous usage of path and mode.\r\nParameter name: remotePath" exception. Could you please provide any workaround for this problem?
Thank you

1 Answer

0 votes
by (70.2k points)

When using TraversalMode.MatchFilesDeep or TraversalMode.MatchFilesShallow, you cannot use paths which explicitly refer to directories. Such paths are for example these:

  • "/dir/"
  • "/dir/."
  • "/dir/.."

You probably used on of above to get the mentioned exception. Am i right?

To learn how to use traversal modes, please see http://blog.rebex.net/download-and-upload-with-ftp-and-sftp-components-using-traversalmode/
The usage for GetItems is same as for Upload and Download.

In short:

  1. to get all files from a specific directory only, use this:

    client.GetItems("/dir/*", TraversalMode.MatchFilesShallow);

  2. to get all items (files and directories without theirs contents) from a specific directory only, use this:

    client.GetItems("/dir/*", TraversalMode.NonRecursive);

...