#include <tchar.h>
#include <Windows.h>
#include <Shlwapi.h>
#pragma comment( lib, "Shlwapi.lib" )
#include <strsafe.h>
bool ForeachFileByDirectory( LPCTSTR pDirectory )
{
if( NULL == pDirectory )
{
return false;
}
//不存在的路径
if( FALSE == PathFileExists( pDirectory ) )
{
return false;
}
//遍历所有类型文件
WIN32_FIND_DATA FindData;
TCHAR Directory[ MAX_PATH ];
StringCbPrintf( Directory, sizeof( Directory ), TEXT( "%s\\*.*" ), pDirectory );
//找到当前目录第一个句柄
HANDLE hFile = FindFirstFile( Directory, &FindData );
if( INVALID_HANDLE_VALUE == hFile )
{
&nbs
C++Windows下递归遍历多级目录
最新推荐文章于 2024-04-30 13:19:22 发布