Feb 14, 2020 at 11:27am Feb 14, 2020 at 11:27am UTC
What I want is to get the list of filenames in a directory. I'm using windows. Apparently system("dir" )
shows the list of files. But I don't need to show them, just get them in a string array. How can I do this?
Feb 14, 2020 at 11:49am Feb 14, 2020 at 11:49am UTC
Hello Rakib771,
The first question is what IDE are you using and do you know what C++ standard the compiler is using?
In C++14 you have "experimental/filesystem" and in C++17 just "filesystem". Not familiar with these, so I do not know if this will do what you want.
Another option system("dir | fileName.txt" )
will send the output if "dir" to a file that you can read and work with.
Andy
Feb 14, 2020 at 12:03pm Feb 14, 2020 at 12:03pm UTC
Hello Rakib771,
My apologies. It has been awhile and I thought the pipe was the proper character. turns out it is ">".
After testing this may work for you.system("dir /B > fileName.txt" )
. This listed just the file names in the directory.
Andy