Advertisement
PIBogdanov

C++

Feb 13th, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <Windows.h>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9.     int fileCount = 0;
  10.  
  11.     string folderPath = "maps/easy/";
  12.  
  13.     // Get the first file in the folder
  14.     WIN32_FIND_DATAA findFileData;
  15.  
  16.     HANDLE hFind = FindFirstFileA((folderPath + "*").c_str(), &findFileData);
  17.  
  18.     // Iterate through the files in the folder
  19.     if (hFind != INVALID_HANDLE_VALUE)
  20.     {
  21.         while (true)
  22.         {
  23.             // Check if the current file is a regular file
  24.             if ( (findFileData.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) == 0 )
  25.             {
  26.                 fileCount++;
  27.             }
  28.  
  29.             if ( !(FindNextFileA(hFind, &findFileData)) )
  30.             {
  31.                 break;
  32.             }
  33.         }
  34.  
  35.         // Clean up
  36.         FindClose(hFind);
  37.     }
  38.  
  39.     cout << "Number of files: " << fileCount << "\n";
  40.  
  41.     return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement