#include #include BOOL IsDirectoryEmpty(const wchar_t* dirname) { WIN32_FIND_DATA findFileData; HANDLE hFind; // パスを作成 wchar_t searchPath[MAX_PATH]; wsprintf(searchPath, L"%s\\*.*", dirname); // ファイルを検索 hFind = FindFirstFile(searchPath, &findFileData); // ディレクトリが見つからない場合は空 if (hFind == INVALID_HANDLE_VALUE) { return TRUE; } // ファイルが見つかった場合はディレクトリが空でない FindClose(hFind); return FALSE; } int wmain() { const wchar_t* directoryPath = L"C:\\Users\\SEEDAGX\\source\\repos\\FolderEmpty\\FolderEmpty\\test"; if (IsDirectoryEmpty(directoryPath)) { wprintf(L"The directory is empty.\n"); } else { wprintf(L"The directory is not empty.\n"); } return 0; }