我正在研究一个C++程序,它会自动将我的工作备份到我的FTP服务器。到目前为止,我能够上传单个文件,通过指定使用此C++遍历文件和目录
CString strFilePath = szFile ;
int iPos = strFilePath.ReverseFind('\\');
CString strFileName = strFilePath.Right((strFilePath.GetLength()- iPos-1));
CString strDirPath = m_szFolderDroppedIn ;
strDirPath = strDirPath.Mid(0,strDirPath.GetLength() - 1);
int iPost = strDirPath.ReverseFind('\\');
CString strDirName = strDirPath.Right((strDirPath.GetLength()- iPost -1));
bool curdir = ftpclient.SetServerDirectory((char*)strDirName.GetBuffer(strDirName.GetLength()));
//Upload to Server
int uploadret = ftpclient.PutFile(szFile,(char*)strFileName.GetBuffer(strFileName.GetLength()),0,true,dwLastError);
m_lsDroppedFiles.RemoveAll();
break;
}
现在我希望能够通过目录遍历(包含子目录)和递归调用的文件名。我在保存目录中的文件时遇到问题。
任何帮助或代码片段...
这很好,但我想找出当前目录中的文件。怎么做 ? – 2010-08-17 05:03:57
@Swapnil:请参阅MSDN中的示例代码。它正在对'C:\\'进行递归搜索 – Naveen 2010-08-17 05:04:56