1 在C++11时,该类库定义在std::tr2::sys命名空间
#include<filesystem>
using namespace std;
using namespace std::tr2::sys;
//示例
void RemoveFile()
{
directory_iterator end, ite("aaa\\");
for (; ite != end; ++ite)
{
auto& thePath = ite->path();
if (!is_directory(thePath))
{
const string& sName = ite->path().filename();
if (sName == "test.txt")
{
remove(thePath);
}
}
}
}
2 上述代码在C++14中编译不过,已经不存在tr2命名空间
filesystem放在std::experimental::filesystem空间
#include <experimental/filesystem>
using namespace std::experimental::filesystem;
但是,在(VS2019,C++14)编译时可能会报错C1189,提示该头文件已被取
3030



被折叠的 条评论
为什么被折叠?



