CInternetSession *m_pInetsession; CFtpConnection *m_pFtpConnection; m_pInetsession=new CInternetSession(AfxGetAppName(),1,PRE_CONFIG_INTERNET_ACCESS); try { m_pFtpConnection=m_pInetsession->GetFtpConnection("127.0.0.1",NULL,NULL,38); MessageBox("连接成功"); } catch(CInternetException *pEx) { TCHAR szError[1024]; if(pEx->GetErrorMessage(szError,1024)) AfxMessageBox(szError); else AfxMessageBox("There was an exception"); pEx->Delete(); m_pFtpConnection=NULL; return; }
BOOL GetFile( LPCTSTRpstrRemoteFile, LPCTSTRpstrLocalFile, BOOLbFailIfExists = TRUE, DWORDdwAttributes = FILE_ATTRIBUTE_NORMAL, DWORDdwFlags = FTP_TRANSFER_TYPE_BINARY, DWORDdwContext = 1 );
pstrRemoteFile
A pointer to a null-terminated string containing the name of a file to retrieve from the FTP server.
pstrLocalFile
A pointer to a null-terminated string containing the name of the file to create on the local system.
bFailIfExists
Indicates whether the file name may already be used by an existing file. If the local file name already exists, and this parameter isTRUE,GetFile fails. Otherwise, GetFile will erase the existing copy of the file.
dwAttributes
Indicates the attributes of the file. This can be any combination of the following FILE_ATTRIBUTE_* flags.
dwFlags
Specifies the conditions under which the transfer occurs. This parameter can be any of thedwFlags values described inFtpGetFile in thePlatform SDK.
dwContext
The context identifier for the file retrieval. See Remarks for more information aboutdwContext.
BOOL Remove( LPCTSTR pstrFileName );
Return Value
Nonzero if successful; otherwise 0. If the call fails, the Win32 functionGetLastError may be called to determine the cause of the error.
Parameters
pstrFileName
A pointer to a string containing the file name to remove.
BOOL PutFile( LPCTSTR pstrLocalFile, LPCTSTRpstrRemoteFile, DWORDdwFlags = FTP_TRANSFER_TYPE_BINARY, DWORDdwContext = 1 );
Return Value
Nonzero if successful; otherwise 0. If the call fails, the Win32 functionGetLastError may be called to determine the cause of the error.
Parameters
pstrLocalFile
A pointer to a string containing the name of the file to send from the local system.
pstrRemoteFile
A pointer to a string containing the name of the file to create on the FTP server.
dwFlags
Specifies the conditions under which the transfer of the file occurs. Can be any of the FTP_TRANSFER_* constants described inOpenFile.
dwContext
The context identifier for placing the file. See Remarks for more information aboutdwContext.
原文地址:http://blog.csdn.net/yusiguyuan/article/details/24989539