findfirstfile和findnextfile用法试用
2012-11-06 17:06 龙成 阅读(746) 评论(0) 编辑 收藏 举报1 CFileFind findfile; 2 BOOL isFind; 3 CString strFind; 4 strFind.Format(_T("%s\\*.*"),strPath); 5 HANDLE hFind = NULL; 6 WIN32_FIND_DATA fileinfo; 7 hFind = FindFirstFile(strFind.GetBuffer(0), &fileinfo); 8 strFind.ReleaseBuffer(); 9 while(TRUE) 10 { 11 CString strFileName; 12 CString tstrFilePath(strPath); 13 strFileName.Format(_T("%s"),fileinfo.cFileName); 14 HICON tmpIcon; 15 tstrFilePath += _T("\\"); 16 tstrFilePath += strFileName; 17 if(fileinfo.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) 18 { 19 if(fileinfo.cFileName[0] != '.') 20 { 21 ((CListBox*)GetDlgItem(IDC_LIST2))->AddString(tstrFilePath); 22 FindAllFile(tstrFilePath); 23 } 24 } 25 else 26 { 27 count++; 28 ((CListBox*)GetDlgItem(IDC_LIST2))->AddString(tstrFilePath); 29 } 30 if(!FindNextFile(hFind,&fileinfo)) 31 break; 32 } 33 FindClose(hFind);