Archived Forum PostQuestion:
Is there a way to have FTP throw an error '0' when downloading a file that exists but has 0 length? I know that I can check the size via FTP but I would like to not have two ftp commands for each file that I am working with.
Thank -Erik
ChilkatLog:
GetFile:
DllDate: Jan 19 2012
UnlockPrefix: SINSVISFTP
Username: MATHIS:erik
Architecture: Little Endian; 32-bit
Language: ActiveX
localFilename: \\8.0.0.19\Archive_eCerts\1745\2005\11\415197.pdf
ModeZ: 0
BinaryMode: 1
Passive transfer mode
EPSV_reply: 229 ENTERING PASSIVE MODE (|||4297|)
hostAddr: 207.97.225.66
DataConnect:
hostname: 207.97.225.66
port: 4297
ConnectTimeoutMs_1: 1000000
calling ConnectSocket2
IPV6 enabled connect with NO heartbeat.
This is an IPV4 numeric address...
AddrInfoList:
AddrInfo:
ai_flags: 4
ai_family: 2
ai_socktype: 1
ai_protocol: 0
ai_addrlen: 16
ai_canonname: (NULL)
--AddrInfo
--AddrInfoList
Connect using IPV4.
ipAddress1: 207.97.225.66
myIP_3: 8.0.0.3
myPort_3: 1219
connect successful (2)
--DataConnect
PassiveDataConnectionSetupTimeMs: Elapsed time: 1172 millisec
RetrFilename: [415197.pdf]
RETR_reply: 150 Opening BINARY mode data connection for 415197.pdf (0 bytes).
This file is known to be 0 bytes in length.
statusCode3: 226
finalReply: 226 Transfer complete (0.000 KB/s).
ReadFinalReplyTimeMs: Elapsed time: 0 millisec
Mdtm:
mdtm: 20060214200331
--Mdtm
TotalTimeMs: Elapsed time: 1860 millisec
Success.
--GetFile
--ChilkatLog
If the file is truly 0 bytes, then it would be wrong to have GetFile return a failed status (0/false) if the file was successfully "downloaded". In this case, "download" means that at 0-length file is created on the client-side.
The Chilkat API's never throw exceptions. The reason is that the API's are supported across so many different programming languages and operating systems, and exceptions are not available in many programming environments. To have some piece of functionality dependent on an exception being thrown would make it non-portable to other environments.
An alternative solution might be to check the size of the local file to see if it's 0 bytes. If so, then you can delete it. This would be much quicker than a 2nd command/response round trip to the FTP server to check the file size.
Not an FTP function, it is up to the receiver and processor to handle that situation. There are many apps that have to have a zero byte file, ie Processing credit cards - process every hours, well if no one runs a card in the hour, have to have a zero byte file.
For any problem, make sure to test with the latest version. If the problem still exists, post the LastErrorText using the latest version.