The Ftp.GetList(string)
method is somewhat problematic. This is from the API documentation:
Caution: The meaning of the arguments argument is not defined by RFC and varies from server to server. Some servers interpret it as parameters to dir command, some as a filename, some ignore it and some report an error. Calling this method with arguments other than null is not recommended and will make your code incompatible with many FTP servers.
One possible workaround for this involves temporarily disabling MLSD
command support, making the GetList
method revert to LIST
command, which might work:
ftp.EnabledExtensions &= ~FtpExtensions.MachineProcessingList;
var list = ftp.GetList("*.XML");
ftp.EnabledExtensions |= FtpExtensions.MachineProcessingList;
...
However, if this doesn't work, that would mean the server does not support wildcard-based file name arguments (it might interpret the argument as a directory path instead), and that you would have to retrieve the whole list and filter it at the client side:
var list = ftp.GetList("*");
string[] files = list.GetFiles("*.XML");
...