CFileFind::IsDirectory
Volání funkce tohoto člena zjistit nalezený soubor je adresář.
BOOL IsDirectory( ) const;
Vrácená hodnota
Nenulová hodnota, pokud je úspěšná. jinak 0.
Poznámky
Soubor, který je adresář je označen atribut souboru uvedený v FILE_ATTRIBUTE_DIRECTORY WIN32_FIND_DATA struktury.
Musíte zavolat FindNextFile nejméně jednou před voláním IsDirectory .
Viz členské funkce MatchesMask úplný seznam atributů souboru.
Příklad
Tento malý program všechny adresáře na jednotce c: recurses a vytiskne název adresáře.
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:"));
}
Požadavky
Záhlaví: afx.h