News:

MASM32 SDK Description, downloads and other helpful links
MASM32.com New Forum Link
masmforum WebSite

probleme with the "FtpGetFile" fonction

Started by tom75000, June 28, 2011, 06:27:39 PM

Previous topic - Next topic

tom75000

Hey there!

I'm new here. I'm asm coder, sorry for my bad english, but it's not my mother tonge :)

I'm working on a ftp program. I'm almost finish. I need just to resolve a problem.

When I want to transfer a file from a ftp server to a local disk, I use the "ftpgetfile" fonction. The returns value is succes (eax=1) but I don't see the file!!! I used procmon, to see the read/write access, I obtain that:

template.exe 2700 WriteFile C:\data.xlsx SUCCESS Offset: 331 776, Length: 2 412

My file is normaly created!! but I see nothing. Something strange too. The programm write the file on a tempory file directory, but I can't see him too


The is my code:
-------------------------------------------------------------------------------------------------------------------
invoke InternetOpen,SADD ("Serveur"), 1, addr NullString, addr NullString, NULL
mov hOpen2, eax

invoke InternetConnect, hOpen2, server, 21, login, pass, 1, NULL, NULL
mov hConnect2, eax

invoke FtpSetCurrentDirectory, hConnect2, SADD ("boutique")

.if action == 1 ; télécharger commandes

invoke GetCurrentDirectory, MAX_PATH, addr currentdirbuffer

invoke FtpFindFirstFile,hConnect2,SADD ("../boutique/*.xlsx"),ADDR DirInfo2,0,0
mov ftpfind2,eax
mov esi,eax

.while Eax!=0

.if dword ptr [DirInfo2.cFileName] == "mmoc"

invoke FtpGetFile, hConnect2, addr DirInfo2.cFileName, SADD ("C:\data.xlsx"), TRUE,FILE_ATTRIBUTE_NORMAL,FTP_TRANSFER_TYPE_BINARY,0
.endif

invoke InternetFindNextFile, esi, ADDR DirInfo2
.endw

invoke InternetCloseHandle,ftpfind2

-------------------------------------------------------------------------------------------------------------------------

Please help me, I don' know my mistake!



purpleendurer

Hi, tom75000

These infomations maybe useful to you.
They are from  http://msdn.microsoft.com/en-us/library/aa384157(v=vs.85).aspx

Remarks
FtpGetFile is a high-level routine that handles all the bookkeeping and overhead associated with reading a file from an FTP server and storing it locally. An application that needs to retrieve file data only or that requires close control over the file transfer should use the FtpOpenFile and InternetReadFile functions.