I'm trying to scan an ftp for any folders or Files that are on it. I can only get it do display the first file. Can someone PLEASE tell me whats wrong with the code below:
Code:
#include <windows.h>
#include <Wininet.h>
#include <iostream.h>
int main()
{
WIN32_FIND_DATA pDirInfo;
WIN32_FIND_DATA pDir2Info;
HINTERNET hDir;
HINTERNET intOpen;
HINTERNET hConnect;
char userName[100]="";
char password[100]="";
char server[100]="";
cout << "Enter the server: ";
cin >> server;
cout << "Enter your user name: ";
cin >> userName;
cout << "Enter your password: ";
cin >> password;
intOpen = InternetOpen("ftp scan dos", INTERNET_OPEN_TYPE_DIRECT,
NULL, NULL,INTERNET_FLAG_ASYNC);
hConnect = InternetConnect(intOpen, server, INTERNET_DEFAULT_FTP_PORT,
userName, password, INTERNET_SERVICE_FTP, INTERNET_SERVICE_FTP, 0);
hDir = FtpFindFirstFile(hConnect, "*.*", &pDirInfo,
INTERNET_FLAG_DONT_CACHE, 0);
cout << "\nRoot Dir Contains:\n" << pDirInfo.cFileName << "\n";
while(InternetFindNextFile (hDir, &pDirInfo))
cout << pDirInfo.cFileName << "\n";
return 0;
}