此小程序递归位于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:")); }
4828

被折叠的 条评论
为什么被折叠?



