#include "stdafx.h"   
#include<windows.h>   
#include<wininet.h>   
#include<iostream>   
#pragma comment(lib,"wininet.lib")using namespace std;void main()   
{   
  
    DWORD byteread=0;   
    HINTERNET hIntSession;  
HINTERNET hFtpSession;
BOOL bsuccess;
HANDLE hFind;
HANDLE localfile;
WIN32_FIND_DATA  finddata ;
SYSTEMTIME systime;
SYSTEMTIME *lpsystime;
FILETIME ftCreate, ftAccess, ftWrite;  //local file time
SYSTEMTIME localsystime;    
    //connect to internet
    hIntSession=InternetOpen("Testing",INTERNET_OPEN_TYPE_PRECONFIG,NULL,NULL,0);   
    if (hIntSession==NULL)   
    {    
        cout<<"Internet open failed!"<<endl;   
        return;   
    }       //connect to ftp
hFtpSession = InternetConnect (hIntSession, TEXT("ftp.microsoft.com"), INTERNET_DEFAULT_FTP_PORT,
        
                             NULL, NULL, INTERNET_SERVICE_FTP, 0, 0) ;
if (hFtpSession==NULL)   
    {    
        cout<<"ftp connect failed!"<<endl;   
        return;   
    }   
    
//set the directory
    bsuccess = FtpSetCurrentDirectory (hFtpSession, TEXT("/bussys/sql/abc/")) ;
if(!bsuccess)
{
cout<<"ftp set directory failed!"<<endl;   
        return;  
}
else cout<<"ftp set directory success!"<<endl;
//search the ftp file
    hFind = FtpFindFirstFile (hFtpSession, TEXT("KB"), &finddata, 0, 0) ;
if(hFind == NULL)
{
cout<<"find ftp file failed!"<<endl;   
                   return;  
}
//get the ftp file systime
FileTimeToSystemTime(&finddata.ftLastWriteTime,lpsystime);
    cout<<"the file createtime is :"<< finddata.ftLastWriteTime.dwLowDateTime<<endl;
cout<<systime.wYear<<endl; cout<<finddata.dwFileAttributes<<endl; //这里不管“kb”是文件夹还是文件,始终打印128,这是怎么回事啊
         cout<<FILE_ATTRIBUTE_DIRECTORY<<endl;
if(finddata.dwFileAttributes==FILE_ATTRIBUTE_DIRECTORY)
{
cout<<"this is a directory"<<endl;
}    FtpGetFile (hFtpSession,finddata.cFileName, "KB", TRUE,
                       FILE_ATTRIBUTE_NORMAL, FTP_TRANSFER_TYPE_BINARY, 0) ;
             
    cout<<"ok"<<endl;}