if (pszPath[strlen(pszPath) - 1] != '\\')
{
_snprintf(szFindPath, sizeof(szFindPath), "%s\\*.*", pszPath);
}
else
{
_snprintf(szFindPath, sizeof(szFindPath), "%s*.*", pszPath);
}
hFind = FindFirstFile(szFindPath, &dataFind);
while (hFind != INVALID_HANDLE_VALUE && bMoreFiles == TRUE)
{
if ((dataFind.dwFileAttributes & FILE_ATTRIBUTE_ARCHIVE) == FILE_ATTRIBUTE_ARCHIVE)
{
// 文件
char szFile[MAX_PATH];
strncpy(szFile, pszPath, sizeof(szFile));
szFile[sizeof(szFile) - 1] = '\0';
if (szFile[strlen(szFile) - 1] != '\\')
{
strcat(szFile, "\\");
}
strcat(szFile, dataFind.cFileName);
szFile[sizeof(szFile) - 1] = '\0'; // szFile完整文件名
}
else if (((dataFind.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == FILE_ATTRIBUTE_DIRECTORY)
&& strnicmp(dataFind.cFileName, ".", strlen(dataFind.cFileName)) != 0
&& strnicmp(dataFind.cFileName, "..", strlen(dataFind.cFileName)) != 0)
{
// 目录
char szPath[MAX_PATH];
strncpy(szPath, pszPath, sizeof(szPath));
if (szPath[strlen(szPath) - 1] != '\\')
{
strcat(szPath, "\\");
}
strcat(szPath, dataFind.cFileName); // szPath完整路径名
FindAll(szPath); // 递归遍历目录
}
bMoreFiles = FindNextFile(hFind, &dataFind);
}