Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #define _CRT_SECURE_NO_WARNINGS
- #include <iostream>
- #include <Windows.h>
- #include <fstream>
- #include <filesystem>
- using namespace std;
- int directory_size(const string& str) {
- int size = 0;
- for (const auto& a : filesystem::directory_iterator(str)) {
- string full_name = str + '/' + a.path().filename().string();
- if (filesystem::is_regular_file(full_name)) {
- size += filesystem::file_size(full_name);
- }
- if (filesystem::is_directory(full_name)) {
- size += directory_size(full_name);
- }
- }
- return size;
- }
- int main() {
- SetConsoleCP(1251);
- SetConsoleOutputCP(1251);
- cout << directory_size("C:/Users/PC/Desktop/Protobuf_windows") << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement