这儿有个类,可行。
// FtpGet.h: interface for the CFtpGet class.#if !defined(AFX_FTPGET_H__9A4CA560_F2F5_11D3_9FF0_0080C8F223E1__INCLUDED_)
#define AFX_FTPGET_H__9A4CA560_F2F5_11D3_9FF0_0080C8F223E1__INCLUDED_#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000class CFtpGet
{
public:// function
CFtpGet();
virtual ~CFtpGet(); // password & user name
bool SetAccessRight(CString userName,CString userPass); // open the connection
bool OpenConnection(CString server); // only one file
bool GetFile(CString remoteFile,
CString localFile); // a full CString array
int GetMultipleFile(CStringArray *remoteArray,
CStringArray *localArray,
int number_file); // close the connection
bool CloseConnection();
private:// var
CInternetSession *pInternetSession;
CFtpConnection *pFtpConnection;
CString strServerName;
CString strPass;
CString strUser;
public:
CString strAppName;
bool missed[100];};#endif // !defined(AFX_FTPGET_H__9A4CA560_F2F5_11D3_9FF0_0080C8F223E1__INCLUDED_)****************************
// FtpGet.cpp: implementation of the CFtpGet class.#include "stdafx.h"
// from my program
// #include "http.h"
//
#include "FtpGet.h"#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////CFtpGet::CFtpGet()
{
// get the name of the app
strAppName.LoadString(AFX_IDS_APP_TITLE); // create an internet session
pInternetSession = new CInternetSession(strAppName,
INTERNET_OPEN_TYPE_PRECONFIG); // if Not good, show message + return
// should never failed anyway
if(!pInternetSession)
{
AfxMessageBox("Can't start internet session");
return;
}}CFtpGet::~CFtpGet()
{
// close the internet session
pInternetSession->Close();
// delete the session
if(pInternetSession != NULL)
delete pInternetSession;}// function, in logical orderbool CFtpGet::SetAccessRight(CString userName,
 CString userPass)
{
// simply get username and password
strPass = userPass;
strUser = userName;
if( (strPass == "") || (strUser == ""))
return 0; return 1;
}bool CFtpGet::OpenConnection(CString server)
{
if(server == "")
return 0; // put the server name in the CFtpGet class
strServerName = server; try {
// try to connect to a ftp server
pFtpConnection = pInternetSession->GetFtpConnection(strServerName,
strUser,
strPass);
} catch (CInternetException* pEx) 
{
// if failed, just show the error // Oops! We failed to connect!
TCHAR szErr[1024];
pEx->GetErrorMessage(szErr, 1024);
TRACE(szErr);
AfxMessageBox(szErr);
pEx->Delete();
return 0;// return 1 but previous error box have been showed
}
return 1;
}bool CFtpGet::GetFile(CString remoteFile,
  CString localFile)
{
// Try to get the file
BOOL bGotFile = pFtpConnection->GetFile(remoteFile,
localFile,
FALSE,
FILE_ATTRIBUTE_NORMAL,
FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE); return bGotFile ? 1 : 0 ;
// if bGotFile is 0 ( FALSE ), return 0
// if bGotFile is 1 ( TRUE  ), return 1
}int CFtpGet::GetMultipleFile(CStringArray *remoteArray,
 CStringArray *localArray,
 int number_file)
{
// init some var
BOOL goodfile;
int x=0;
int nb_lost_file =0; // while loop to transfer every file in the array
while(x<number_file)
{
// try to get file
goodfile = pFtpConnection->GetFile(remoteArray->GetAt(x),
localArray->GetAt(x),
FALSE,
FILE_ATTRIBUTE_NORMAL,
FTP_TRANSFER_TYPE_BINARY | INTERNET_FLAG_RELOAD | INTERNET_FLAG_NO_CACHE_WRITE); missed[x] = goodfile ? 0 : 1;
// if failed, missed[x] become 1
// if good, missed become 0
if(missed[x])
nb_lost_file++;
// if the file was missed, increase the number of 
// missing file.
// increase to the next file
x++;
}
//return the number of missing file, if any.
return nb_lost_file;
}bool CFtpGet::CloseConnection()
{
// close the connection to server, you can reconnect latter
if(pFtpConnection == NULL)
return 0;
try{
pFtpConnection->Close();
}catch(...)
{
return 0;
}
if(pFtpConnection != NULL)
delete pFtpConnection; return 1;
}