Advertisement
35657

Untitled

Apr 27th, 2024
541
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.67 KB | None | 0 0
  1. #define _CRT_SECURE_NO_WARNINGS
  2.  
  3. #include <iostream>
  4. #include <Windows.h>
  5. #include <fstream>
  6. #include <filesystem>
  7.  
  8. using namespace std;
  9.  
  10.  
  11.  
  12.  
  13. void print_directory_info(const string& str) {
  14.     for (const auto& a : filesystem::directory_iterator(str)) {
  15.         cout << setw(30) << a.path().filename().string();
  16.         string full_name = str + '/' + a.path().filename().string();
  17.         if (filesystem::is_regular_file(full_name)) {
  18.             cout << '\t' << filesystem::file_size(full_name);
  19.         }
  20.         cout << endl;
  21.     }
  22. }
  23.  
  24.  
  25. int main() {
  26.     SetConsoleCP(1251);
  27.     SetConsoleOutputCP(1251);
  28.  
  29.    
  30.     print_directory_info("C:/Users/PC/Desktop");
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement