차근차근/C

[C++] 하위 폴더 검색 최간편 소스

예쁜꽃이피었으면 2014. 8. 4. 15:45
http://lispro06.woweb.net/app/1578

하위 폴더 검색 최간편 소스

#include "stdafx.h"
#include "windows.h"
#include "winbase.h"
#include "stdio.h"
#include "cstringt.h"
#include "atlstr.h"

bool FindnFile( const char *strPath ) 
{
bool bContinue = true;
WIN32_FIND_DATA FindFileData;
HANDLE hFind;
char strFindPath[ 1024 ], strFileName[ 1024 ];
sprintf( strFindPath, "%s*.*", strPath );
hFind = FindFirstFile( strFindPath, &FindFileData );
if( hFind == INVALID_HANDLE_VALUE ) return false;

while( bContinue )
strcpy( strFileName, FindFileData.cFileName );
if( ( FindFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY ) == FILE_ATTRIBUTE_DIRECTORY )
if( strcmp( strFileName, "." ) !=0 && strcmp( strFileName, ".." ) != 0 )
sprintf( strFindPath, "%s%s", strPath, strFileName );
FindnFile( strFindPath );
}
}
else {

CString FullPathName;
FullPathName.Format("%s%s", strPath, strFileName );
printf("%s",FullPathName);
}

if( FindNextFile( hFind,&FindFileData ) == FALSE )
bContinue=false;
}
FindClose( hFind );
return true;
}


반응형

'차근차근 > C' 카테고리의 다른 글

C 언어 레퍼런스 - atol 함수  (0) 2014.08.06
flush  (0) 2014.08.05
MSB3073 에러  (0) 2014.08.01
비쥬얼 스튜디오 디버깅 팁 ( Visual Studio Debugging Tips )  (0) 2014.07.30
C 사용자를 위한 C++  (0) 2014.07.29