literal ? and * in IFtp.GetItems

+1 vote
asked Nov 2 by rexh (580 points)

Since the characters '?' and '*' are valid FTP filenames, how do I deal with that in IFtp.GetItems.
For example, I have a folder named "?" at the root, and when I try to enumerate it's contents, I will call:
ftp.GetItems("/?", TraversalMode.Recursive)
but this is giving me recursive contents of the root folder "/" instead.
How do I specify a literal "?" as the folder name? Any way to escape it?

1 Answer

0 votes
answered Nov 2 by Lukas Matyska (58,290 points)
selected Nov 3 by rexh
Best answer

There is no way to escape wildcards at the moment.

However, your example can be implemented simply by using FileSet class with basePath set to "/?" (basePath does not evaluate any wildcards). It can be done like this:

var fset = new FileSet("/?", "*", TraversalMode.Recursive);
commented Nov 3 by rexh (580 points)
That works. Thank you very much!