Ik ben nu bezig met een kleine applicatie die mbv WinInet verbinding maakt met een FTP-server. Nu heb ik een eigen ftp draaien, dus ik zie of hij wel of niet connect.Het connecten gaat op zich goed, maar dan wil ik een lijst maken met de mappen en bestanden. Daarvoor gebruik ik de functie FtpFindFirstFile(); eerst een stukje code:
Als uitvoer krijg ik:
Error code 27, volgens msdn staat dat voor een incorecte parameter.
http://msdn.microsoft.com...m_error_codes__0-499_.asp
Volgens mij gaat het mis bij de 2de arg van FtpFindFirstFile(), msdn zegt:
C++:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
| if((findFile = FtpFindFirstFile( handleInternet, NULL, win32_find_data, INTERNET_FLAG_NO_CACHE_WRITE, NULL)) != NULL) cout<<"FtpFindFirstFile() succed\n"; if(InternetFindNextFile( findFile, win32_find_data)) cout<<"InternetFindNextFile() succeed"<<endl; else cout<<GetLastError()<<endl; if(FtpOpenFile ( handleInternet, win32_find_data->cFileName, GENERIC_READ, FTP_TRANSFER_TYPE_BINARY, NULL) != NULL) cout<<"FtpOpenFile() succeed\n"; else { cout<<GetLastError()<<endl; } |
Als uitvoer krijg ik:
code:
1
2
3
4
5
6
| InternetOpen() succeed InternetConnect() succed FtpFindFirstFile() succed 87 87 Disconnected |
Error code 27, volgens msdn staat dat voor een incorecte parameter.
http://msdn.microsoft.com...m_error_codes__0-499_.asp
Volgens mij gaat het mis bij de 2de arg van FtpFindFirstFile(), msdn zegt:
Ik wil dus een lijst met alle mappen en bestanden in de root, dus ik geef een NULL arg mee. En met InternetFindNextFile() wil ik het volgende bestand vinden, net zo lang tot er nix meer te vinden is. Maar dat wil dus niet echt, iemand enige idee hoe het wel moetlpszSearchFile
[in] Pointer to a null-terminated string that specifies a valid directory path or file name for the FTP server's file system. The string can contain wildcards, but no blank spaces are allowed. If the value of lpszSearchFile is NULL or if it is an empty string, the function finds the first file in the current directory on the server.