SearchDirectory( "g:\\공부 문서\\" );

list< char * > m_ListTotalFileName;


int CFileDlg::SearchDirectory(const char *parm_search_path)

{

CString search_path = parm_search_path;

char *pFileName;

int nSearchPathLen;



WIN32_FIND_DATA file_data;

// 현재 경로의 모든 파일과 디렉토리를 찾는다.

HANDLE search_handle = FindFirstFile(search_path + "*.*", &file_data);

if(INVALID_HANDLE_VALUE != search_handle){

do{

if(FILE_ATTRIBUTE_DIRECTORY & file_data.dwFileAttributes)

{

// 폴더인 경우...

// 현재 폴더(.)와 이전폴더("..")를 의미하는 심볼은 제외시킨다.

if(file_data.cFileName[ 0 ] != '.')

{

// 서브 디렉토리를 계속 검색한다.

SearchDirectory(search_path + file_data.cFileName + CString("\\") );

}

else 

{

m_CListBox.InsertString(-1, "[FILE]: " + search_path + file_data.cFileName);

m_TotalCount ++;

m_TotalBytes += file_data.nFileSizeLow;


pFileName = new char [ MAX_PATH ];

nSearchPathLen = strlen( search_path );

strcpy_s( pFileName, nSearchPathLen + 1, search_path );

strcpy_s( pFileName + nSearchPathLen, strlen( file_data.cFileName ) + 1, file_data.cFileName );

m_ListTotalFileName.push_back( pFileName );

}

} while(FindNextFile(search_handle, &file_data));

FindClose(search_handle);

}


return 0;

}


'NativeCode > mfc' 카테고리의 다른 글

파일 찾기  (0) 2010.03.18
폴더 선택 다이알로그 BROWSEINFO  (0) 2010.03.18
현재 위치 구하기  (0) 2010.03.18
프로세스 찾아 죽이기  (0) 2010.03.18
하드 용량 체크  (0) 2010.03.18

+ Recent posts