0 votes
by (160 points)
edited by

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)

Applies to: Rebex FTP/SSL

1 Answer

+1 vote
by (147k points)
selected by
 
Best answer

Please create a communication log using Ftp object's LogWriter property (see the KB article on logging for details) and either post it here or mail it to support@rebex.net for analysis. This should make it possible to tell what is going on.

However, the stack trace of the FormatException seems to suggest that this might not be occurring within our assemblies because none of them calls System.Number.ParseDouble. Would it be possible to provide the whole exception chain instead of just the Message/StackTrace of the top-level exception? Calling the Exception's ToString() method to get that.

by (160 points)
I sent the file to mentioned email (too long to attach here)

I'm still trying to get more information about the exception, but for some yet unknown reason, the Exception is not thrown. During debugging it shows the Exception, but the program just continues as if nothing happened. I get the exception for each subdirectory (which I have 200+ of)
I noticed that the file does get picked up if I ignore the exceptions, but sounds like bad practice if the program should just ignore all 200+ exceptions every time this script is called, which is every few minutes
by (147k points)
Thanks for the log and for the additional information that made it possible for us to pinpoint the problem. It turned out this is actually caused by a try/catch in our FTP listing parser which uses double.Parse, so any value it cannot parse triggers a FormatException. Although this is caught immediately by our code, Visual Studio's debugger still reports it. Together with a small bug in the parser, this caused the issue you reported. Thanks for lettings us know about this, and sorry for inconvenience!
We will fix this for the next release. If you are interested in a hotfix, please let us know.
...