1.连接服务器:
try
{
m_ftpConnect=new CFtpConnection(((CMyApp *)::AfxGetApp())->
m_pInetSession,m_applicationName,m_username,m_password,m_port);
((CStatic *)GetDlgItem(IDC_MANUALDLG_WAITING_STATIC))->ShowWindow(SW_HIDE);
if (m_ftpConnect != NULL)
{
CString m_i;
m_i=_T("connect success/r/n");
m_ftpInfo +=m_i;
UpdateData(FALSE);
//m_inetSession.CloseFtpConnect();
m_ftpConnect->Close();
delete m_ftpConnect;
AfxMessageBox(m_ftpInfo);
OnOK();
}
}
catch (CInternetException * pEx)
{
((CStatic *)GetDlgItem(IDC_MANUALDLG_WAITING_STATIC))->ShowWindow(SW_HIDE);
CString m_i;
m_i=_T("connect failure/r/n");
m_ftpInfo +=m_i;
UpdateData(FALSE);
TCHAR szError[1024];
if ( pEx->GetErrorMessage(szError,1024))
{
m_i=(CString) szError;
m_ftpInfo +=m_i;
UpdateData(FALSE);
AfxMessageBox(m_ftpInfo);
}
else
AfxMessageBox(_T("There was an exception"));
pEx->Delete();
}
}
2.CFtpFileFind
CFtpFileFind ftpFileFind(m_pFtpConnection);
//BOOL bWorking=ftpFileFind.FindFile(m_strCurrentDirectory);
//BOOL bWorking=ftpFileFind.FindFile(m_strCurrentDirectory,INTERNET_FLAG_RELOAD|INTERNET_FLAG_EXISTING_CONNECT);
BOOL bWorking=ftpFileFind.FindFile(_T("*"));
while(bWorking)
{
bWorking=ftpFileFind.FindNextFile();//注意这句一定要放前面,否则在后面ftpFileFind调用任何函数都错误
//::AfxMessageBox();
if(ftpFileFind.IsDirectory())
{
//if(ftpFileFind.GetFileName()==
}
/*if(bWorking)
{
bCreateDirectory=TRUE;
}*/
}
ftpFileFind.Close();
3.CFtpFileFind的两个函数的区别(IsDirectory() / IsDots())
//if(finder.IsDirectory() && !finder.IsDots()) //如果是目录
IsDirectory判断是否为目录
IsDots判断是否为点或者点点--这个要说明一下,你用过Dos的话,就应该知道,每个目录下都有缺省的两个目录,名称分别为'.'和'..',分别代表上一层目录和本层目录。因此,当我们在遍历目录下文件时,需要过滤掉这两个缺省目录。