判断文件存在
boost::filesystem::exists( fileFullPath )
删除文件
boost::filesystem::remove( filePath )
删除文件夹(递归删除)
boost::filesystem::remove_all( folderPath )
列举目录中所有的文件
boost::filesystem::path path_Dir( "D:\\Temp\\" );
boost::filesystem::directory_iterator end_iter;
for (boost::filesystem::directory_iterator iter(path_Dir); iter != end_iter; iter++)
{
if (!boost::filesystem::is_regular_file(iter->status()))
{
continue;
}
boost::filesystem::remove( iter->path() );
}
获取文件所在的文件夹
string fileFullPath = "D:\\temp\\hello.dat";
boost::filesystem::path fileFullPath_Path(fileFullPath);
string fileParentDir = fileFullPath_Path.parent_path().string();