tags:

views:

130

answers:

2

I want to download all file from ftp directory i want use for that FtpFindFirstFile and FtpGetFile;

LPWIN32_FIND_DATA FileData; 
TCHAR* APP_NAME = TEXT("ftpcli");
TCHAR* PATH_FTP = TEXT("ftp://127.0.01");
TCHAR* ADR_FTP = TEXT("127.0.0.1");
TCHAR* LC_FILE = TEXT("C:\\!");
TCHAR* PATH_FILE = TEXT("/Soft/DVD_Players/WinDVD6");
UINT a;
HINTERNET opn;
HINTERNET conn;
a = InternetAttemptConnect(0);
if (a == ERROR_SUCCESS ) {
    if(InternetCheckConnection(PATH_FTP,FLAG_ICC_FORCE_CONNECTION, NULL)) {
        opn = InternetOpen(APP_NAME, INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, INTERNET_FLAG_ASYNC);
        conn = InternetConnect(opn, ADR_FTP, INTERNET_DEFAULT_FTP_PORT, NULL, NULL, INTERNET_SERVICE_FTP, NULL, NULL);          
        FtpSetCurrentDirectory(conn, PATH_FILE);
        FtpFindFirstFile(conn, NULL, &FileData, INTERNET_FLAG_NEED_FILE, NULL);
        FtpGetFile(conn, FileData->cFileName, LC_FILE, FALSE, FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, NULL);
    }
}

That code return error i know that because i do not identified memory on LPWIN32_FIND_DATA. But i do not know how do it.

A: 
Joe
Yeah and `"ftp://127.0.01"` should probably be `"ftp://127.0.0.1"`
jpalecek
+3  A: 

You've declared a pointer to WIN32_FIND_DATA, you need a concrete instance of that structure. Fix:

WIN32_FIND_DATA FileData;   // NOTE: not LP
Hans Passant