DownloadFileEx fails

Hello,
I ran into strange problem. If i try to download file for the first time DowloadFileEx returns ftpErrorSuccess but downloaded file is zero size. However if i try to download same file right away in same method in my code it downloads just fine. Here is how it looks in library log:

[20081001 07:59:31] PASV
[20081001 07:59:31] 227 Entering Passive Mode (81,7,90,53,201,34)
[20081001 07:59:31] Passive ip address returned from server different from server ip.
[20081001 07:59:31] Opening data connection to 81.7.90.53 Port: 51490
[20081001 07:59:31] RETR conf.xml
[20081001 07:59:31] 150 Opening BINARY mode data connection for conf.xml (1728 Bytes).
[20081001 07:59:31] 0 bytes transferred. (0 bytes/s) (234 ms)
[20081001 07:59:32] 226 Transfer complete.
[20081001 07:59:43] PASV

[20081001 07:59:43] 227 Entering Passive Mode (81,7,90,53,208,69)
[20081001 07:59:43] Passive ip address returned from server different from server ip.
[20081001 07:59:43] Opening data connection to 81.7.90.53 Port: 53317
[20081001 07:59:43] RETR conf.xml
[20081001 07:59:43] 150 Opening BINARY mode data connection for conf.xml (1728 Bytes).
[20081001 07:59:43] 1728 bytes transferred. (7.21 KB/s) (234 ms)
[20081001 07:59:43] 226 Transfer complete.


I use the following code:



m_pConnection.CoCreateInstance(__uuidof(FTPConnectionSTA));
m_pUPnP.CoCreateInstance(__uuidof(UPnPNATManager));
m_pUPnP->Initialize());

m_pConnection->Async = VARIANT_FALSE;
m_pConnection->Host = (_bstr_t)m_bstrHostName;
m_pConnection->Port = m_nPort;
m_pConnection->Username = (_bstr_t)m_bstrUserName;
m_pConnection->Password = (_bstr_t)m_bstrPassword;
m_pConnection->LogFile = L"C:\\sftp.log";
m_pConnection->Passive=VARIANT_TRUE;
m_pConnection->PassiveForceIP=VARIANT_FALSE;
m_pConnection->DataTransferKeepAlive=VARIANT_TRUE;

m_pConnection->Connect();

enumError error=m_pConnection->DownloadFileEx(szFileName, L"c:\\test", 0, 0, 0, 0);

So what am i doing wrong? SmartFtp Client downloads this file just fine.

Thank you.

You have to verify your downloads. It means after the DownloadFileEx() function compare the size of the local file with the size of the remote file. If they are equal your download is successful otherwise repeat the download.

Regards,
Mat

I see. The problem is this happens to every single file i'm trying to download. So i'm just wondering is it smartftp library problem or some problem with my firewall/router etc

It might be a software firewall problem. Try to add your application to the exceptions in your software firewall (e.g. Windows Firewall). SmartFTP does this automatically so this might be the reason it works with SmartFTP.

Regards,
Mat