Convert boost/filesystem to string

Viewed 74

I'm trying to convert boost::filesystem type to string, but it tell me that "string()" is not a member of the boost::filesystem :

void myClass::encryptFile()
{ 
// Récursion sur un chemin donné
for (boost::filesystem::recursive_directory_iterator end, dir(DirPath); dir != end; ++dir) 
{   
    // Vérification du type de l'objet
    if (!boost::filesystem::is_regular_file(*dir))
    {
    
    
        string ptext = *dir.string();
                    
    }
    
}

How to convert *dir to string ?

1 Answers

Get the boost::filesystem::path first.

void myClass::encryptFile()
{ 
// Récursion sur un chemin donné
for (boost::filesystem::recursive_directory_iterator end, dir(DirPath); dir != end; ++dir) 
{   
    // Vérification du type de l'objet
    if (!boost::filesystem::is_regular_file(*dir))
    {
    
    
        string ptext = dir->path().string();
                    
    }
    
}
Related