How to read files in a directory? [closed]
Hello
I need to read some files from a directory and the std::filesystem
does not seems to work. I already tried std::experimental::filesystem
but I get the same error ‘std::filesystem’ has not been declared
respectively ‘std::experimental::filesystem’ has not been declared
. Is there any other way to read files?
std::vector<std::string> get_folder_content(std::string path)
{
std::vector<std::string> files;
std::filesystem::directory_iterator path_iterator(path);
for (const auto& entry : path_iterator)
{
files.push_back(entry.path().string());
}
return files;
}
I'm sorry to close your question, especially since it already has an answer, but this is not a ROS question. It's a general C++ question. Please keep your ROS Answers questions on topic, meaning: they should ask questions about ROS.
For all other questions (about programming, robotics, math, etc), try to find an appropriate forum, such as Stack Overflow, the Ubuntu fora, Robotics Stack Exchange, etc.