I have written the below simple method for downloading all files from specified directory to a local directory. This works perfectly fine when all the files are in a directory, but I can't get it working when I need to download all files from root directory.
Private Sub DownloadFiles(serverPath As String, localPath As String)
Using ftp As IFtp = _ftpConnection()
Dim serverFilePathPattern As String = serverPath + _fileNameMask
ftp.Download(serverFilePathPattern, localPath, TraversalMode.MatchFilesShallow, TransferMethod.Move, ActionOnExistingFiles.SkipAll)
ftp.Disconnect()
End Using
End Sub
E.g. when serverPath is "Test/[asterisk].txt" it will correctly download all txt files from /Test/ directory, but if I set serverPath to "[asterisk].txt" or "/[asterisk].txt" it will throw a useless exception:
EDIT: For some annoying reason asterisk is removed, so imagine that [asterisk] is replaced with an actual asterisk :)
Type: FormatException
Message: Input string was not in a correct format.
StackTrace: at System.Number.ParseDouble(String value, NumberStyles options, NumberFormatInfo numfmt)