The Chilkat FTP2 component provides a GetSizeStr method to retrieve the size of a file as a string. This allows the size to be converted to a 64-bit integer in any programming language. Here is an example in VB.NET.
The GetSizeStr returns the size of the Nth file in the directory (matching the ListPattern). If the ListPattern is set to the exact filename without wildcard characters, then only one file will match (if it exists). Therefore, GetSizeStr(0) returns the size of the file specified by ListPattern:
' Set the current remote directory to where the file is located:
success = ftp.ChangeRemoteDir("/temp")
If (success <> True) Then
MsgBox(ftp.LastErrorText)
Exit Sub
End If
' Set the ListPattern to the exact filename.
ftp.ListPattern = "hamlet.xml"
If (ftp.NumFilesAndDirs = 1) Then
' If it exists, NumFilesAndDirs = 1
' Get the file size as an integer string.
Dim fileSizeStr As String
fileSizeStr = ftp.GetSizeStr(0)
' ULong is a 64-bit integer in VB.NET
Dim fileSize64 As ULong
fileSize64 = System.Convert.ToUInt64(fileSizeStr)
MsgBox(fileSize64)
End If