C++ How to put the names of files within a directory into a vector?

Dee

I simply need to put all the files (or file names?) within a directory into a vector so that I can sort them and open them in order.

I literally have no idea how to do this since this my first encounter with C++. I have tried boost::filesystem but I am having no success as this is quite unfamiliar to me. Please help!

I've actually found a method I think will work however I am now struggling with adding a linker to the command line but I think if I ask about that here it'll exceed the scope of the original question.

stefaanv

taken from your previous question:

std::vector<std::string> filenames;
dpdf = opendir("/data/files");
if (dpdf != NULL) {
   while (epdf = readdir(dpdf)) {
      filenames.push_back(std::string(epdf->d_name));
   }
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

how to suppress directory names in tar archived files?

From Java

How many files can I put in a directory?

From Dev

How to move files within the Hadoop HDFS directory?

From Dev

How to rename the multiple files within a directory

From Dev

How to change names of files in a directory to random generated names?

From Dev

How to aggregate matrices within a list based on vector of names?

From Dev

PYTHON - How to change one character in many file names within a directory

From Dev

How to copy files within directory rather than a whole directory in TCL?

From Dev

Get files names in directory

From Dev

Search for files within a directory

From Dev

How to put numbers of an integer in a vector in C++

From Dev

How to rename a group of files by moving a pattern within the file names

From Dev

python printing the path names of .c files from a directory tree

From Dev

Directory.getfiles(): specific names of files c#

From Dev

How to determine how many files are within a directory without counting?

From Dev

PHP - find all all files within directory that match certain string and put in array

From Dev

How can I format a list of files with directory names in unix?

From Dev

how to open files names from directory dialog in pyqt

From Dev

How to check that the audio files in a directory match the file names stored in a database

From Dev

How to move the files to new directory based on names in text file?

From Dev

how can i return the names of files in a directory using php

From Dev

How to symbolic link the files to new directory based on names in text file?

From Dev

How to remove files from a directory if their names are not in a text file? Bash script

From Dev

How to put the specific files from a directory in an array in bash?

From Dev

How to put the specific files from a directory in an array in bash?

From Dev

how to replacing some files within a certain directory inside a jar file?

From Dev

How to find all files with the same extension within a directory

From Dev

How to find all files with the same extension within a directory

From Dev

How can I find all files open within a given directory?

Related Related

  1. 1

    how to suppress directory names in tar archived files?

  2. 2

    How many files can I put in a directory?

  3. 3

    How to move files within the Hadoop HDFS directory?

  4. 4

    How to rename the multiple files within a directory

  5. 5

    How to change names of files in a directory to random generated names?

  6. 6

    How to aggregate matrices within a list based on vector of names?

  7. 7

    PYTHON - How to change one character in many file names within a directory

  8. 8

    How to copy files within directory rather than a whole directory in TCL?

  9. 9

    Get files names in directory

  10. 10

    Search for files within a directory

  11. 11

    How to put numbers of an integer in a vector in C++

  12. 12

    How to rename a group of files by moving a pattern within the file names

  13. 13

    python printing the path names of .c files from a directory tree

  14. 14

    Directory.getfiles(): specific names of files c#

  15. 15

    How to determine how many files are within a directory without counting?

  16. 16

    PHP - find all all files within directory that match certain string and put in array

  17. 17

    How can I format a list of files with directory names in unix?

  18. 18

    how to open files names from directory dialog in pyqt

  19. 19

    How to check that the audio files in a directory match the file names stored in a database

  20. 20

    How to move the files to new directory based on names in text file?

  21. 21

    how can i return the names of files in a directory using php

  22. 22

    How to symbolic link the files to new directory based on names in text file?

  23. 23

    How to remove files from a directory if their names are not in a text file? Bash script

  24. 24

    How to put the specific files from a directory in an array in bash?

  25. 25

    How to put the specific files from a directory in an array in bash?

  26. 26

    how to replacing some files within a certain directory inside a jar file?

  27. 27

    How to find all files with the same extension within a directory

  28. 28

    How to find all files with the same extension within a directory

  29. 29

    How can I find all files open within a given directory?

HotTag

Archive