bool CDirByLinkedListDlg::AddSubFolders(CsaLinkedList& lnk, LPCTSTR pszBaseFolder) { CString strBaseFolder; CFileFind ff; CString strFind; BOOL bLoop; bool bRet = false; // 念のため、pszBaseFolder が存在することを確認しておきます。 strBaseFolder.Format(_T("%s"), pszBaseFolder); if (!strBaseFolder.Right(1).CompareNoCase(_T("\\"))) { // \ 終わりの場合 strBaseFolder = strBaseFolder.Left(strBaseFolder.GetLength() - 1); // \ を外す } if (!ff.FindFile(strBaseFolder)) { return false; // 指定されたベースフォルダがない } ff.FindNextFile(); if (!ff.IsDirectory()) { // フォルダではない ff.Close(); return false; } ff.Close(); // 指定のベースフォルダにあるサブフォルダを取得します。 strFind.Format(_T("%s\\*.*"), strBaseFolder); if (ff.FindFile(strFind)) { do { bLoop = ff.FindNextFile(); // フォルダの場合のみ、リストに追加します。 if (ff.IsDirectory() && !ff.IsDots()) { lnk.AddString(ff.GetFilePath()); bRet = true; } } while (bLoop); ff.Close(); } return bRet; }