I am working on a program which requires me to, at multiple points, import the contents of a subdirectory of my C++ Project, into a vector<string>
. Assuming the project directory is called root\
and the directory I want to scan is root\userFiles
. This folder only contains additional files and no further subfolders.
However the trick is I am restricted, I cannot use any of the boost, dirent.h header files. Just the basic ones.
One solution I was able to come up with was the use of the command system( "dir /b * > userFiles/fileList.txt" );
and then filter the results in by reading that file and importing it into the vector.
My issue is how do I "cd" to that folder, run that command while still in that folder, and then exit back to the root folder..
I have tried using the system("chdir userFiles/")
command but I am still getting all the files in the root folder.
Any help would be appreciated.