CFileFind::IsDirectory
찾은 파일 디렉터리에 있는지 확인 하려면이 멤버 함수를 호출 합니다.
BOOL IsDirectory( ) const;
반환 값
성공 하면 0이 아닌. 그렇지 않으면 0입니다.
설명
디렉터리에 있는 파일 FILE_ATTRIBUTE_DIRECTORY 파일 특성 확인에 표시 되어 있는 WIN32_FIND_DATA 구조.
호출 해야 FindNextFile 호출 하기 전에 적어도 한 번 IsDirectory.
멤버 함수를 참조 하십시오. MatchesMask 파일 특성의 전체 목록은.
예제
이 작은 프로그램 재귀: C:\ 드라이브의 모든 디렉터리와 디렉터리의 이름을 출력 합니다.
void Recurse(LPCTSTR pstr)
{
CFileFind finder;
// build a string with wildcards
CString strWildcard(pstr);
strWildcard += _T("\\*.*");
// start working for files
BOOL bWorking = finder.FindFile(strWildcard);
while (bWorking)
{
bWorking = finder.FindNextFile();
// skip . and .. files; otherwise, we'd
// recur infinitely!
if (finder.IsDots())
continue;
// if it's a directory, recursively search it
if (finder.IsDirectory())
{
CString str = finder.GetFilePath();
TRACE(_T("%s\n"), (LPCTSTR)str);
Recurse(str);
}
}
finder.Close();
}
void PrintDirs()
{
Recurse(_T("C:"));
}
요구 사항
헤더: afx.h