1

I have an error when I try to list a simple .pdf on my desktop.

#include <string>
#include <iostream>
#include <filesystem>
#include <vector>
using namespace std;
namespace fs = std::filesystem;

int main()
{
    unsigned long int nbFile = 0;
    unsigned long size = 0;
    string path = R"(C:\Users\Adam\Desktop\)";
    for ( const auto &entry : fs::recursive_directory_iterator((path), fs::directory_options::skip_permission_denied)) {
            if (fs::is_regular_file(entry.path())){
                cout << entry.path() << endl;
                nbFile++;
                size += entry.file_size();
            }
    }
    cout << "Nombre de fichier : " << nbFile << "\nSize : " << size << endl;

    system("pause");
    return 0;
}

image

Remy Lebeau
  • 555,201
  • 31
  • 458
  • 770
  • Error `0xC0000409` is `STATUS_STACK_BUFFER_OVERRUN`. Where a buffer overrun is ocuring in this code, who knows. That is what a debugger is for. – Remy Lebeau Feb 12 '20 at 20:54
  • https://stackoverflow.com/q/25385173/5910058 – Jesper Juhl Feb 12 '20 at 20:55
  • I'm guessing that the impl for directory iterator is allocating memory, and since you're at such a high level directory, it's running out of memory – AndyG Feb 12 '20 at 21:00
  • Does it work fine if you run the program from a more localized directory? – AndyG Feb 12 '20 at 21:06
  • Welcome to stack overflow. I noticed that you found an answer to your own question. Two observations: Speaking from my own experience, it is easier if you provide a minimal example. Notice how with your question, as it stands right now, it would have been impossible to find an answer (you didn't provide the full path to the file). Also, posting an image of your IDE didn't provide useful information. It is better to provide the relevant error in plain text. – JACH Feb 12 '20 at 21:46

1 Answers1

0

I find the problem the program can't convert caracter from a pdf file so i use wstring.