18,356
社区成员
发帖
与我相关
我的任务
分享
void GetFtpServerFileList(CString strDir)
{
CString FileName=_T("");
CStringList List;
if (!g_FtpInfo.pFtpConnection->SetCurrentDirectory(strDir))
{
DPIDebugPrintWithArgs(LOG_LEVEL_ERROR,"Exec SetCurrentDirectory'function is failed,Error:%d",GetLastError());
return;
}
CFtpFileFind finder(g_FtpInfo.pFtpConnection);
BOOL bFind=finder.FindFile(_T("*"));
while (bFind)
{
bFind=finder.FindNextFile();
if (finder.IsDots())
continue;
//不是文件夹的话
if (!finder.IsDirectory())
{
//根据需要保存地址或做其他操作,这里保存的是文件在ftp服务器上的相对路径
gFileArray.Add(finder.GetFilePath());
continue;
}
else
{
//保存目录
List.AddTail(finder.GetFilePath());
}
}
//这个需要关闭,只能有一个CFtpFileFind
finder.Close();
while (List.IsEmpty()==FALSE)
{
strDir=List.RemoveHead();
GetFtpServerFileList(strDir);
}
}