#include #include #include void listDirectoriesRecursively(const TCHAR* basePath) { TCHAR searchPath[MAX_PATH]; WIN32_FIND_DATA findData; HANDLE hFind; _stprintf_s(searchPath, _countof(searchPath), _T("%s\\*"), basePath); hFind = FindFirstFile(searchPath, &findData); if (hFind == INVALID_HANDLE_VALUE) { _tprintf(_T("Failed to find first file.\n")); return; } do { if (findData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) { if (_tcscmp(findData.cFileName, _T(".")) != 0 && _tcscmp(findData.cFileName, _T("..")) != 0) { _tprintf(_T("%s\\%s\n"), basePath, findData.cFileName); TCHAR newPath[MAX_PATH]; _stprintf_s(newPath, _countof(newPath), _T("%s\\%s"), basePath, findData.cFileName); listDirectoriesRecursively(newPath); } } } while (FindNextFile(hFind, &findData) != 0); FindClose(hFind); } int _tmain(int argc, TCHAR* argv[]) { const TCHAR* basePath = _T("C:\\Users\\SEEDAGX\\source\\repos\\GetSubFolder"); // ここにベースフォルダのパスを指定してください listDirectoriesRecursively(basePath); return 0; }