Hi:

Yes, the filename object is a class, so in order to get a std::string—assuming your not using Unicode out for the filename, you need to call generic_string as previously stated.

If you wre using Unicode std::wstring you would call generic_string.

This will give you the filename +the extension, you can trim the extension off if you need using the string algo library—it’s part of the filename object itself.

Hth

Sean.

 

From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Amanullah Yasin
Sent: 11 July 2011 14:41
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] Help is required to get the file names in a directory...........

 

Yes, i am populating a string vector.

 vector<string> listOfFiles;

Can you give some more detail?

 

Thanks

 

aman



On Mon, Jul 11, 2011 at 3:32 PM, Sean Farrow <sean.farrow@seanfarrow.co.uk> wrote:

Hi:

Where you are adding file names to the vector call the generic_string method of the file name object, and this should work.

Hth

Sean.

From: boost-users-bounces@lists.boost.org [mailto:boost-users-bounces@lists.boost.org] On Behalf Of Amanullah Yasin
Sent: 11 July 2011 13:19
To: boost-users
Subject: [Boost-users] Help is required to get the file names in a directory...........

 

Hello,
Before, with boost 1.38 and visual studio 2005, i was using following funtion to retrieve the file names in a folder. 
Now i switched to boot 1.46.1 and visual studio 2010, but the following method is not working. Please guide me.

void Compilation::getFileNames(vector<string>& listOfFiles)

      {

     

      boost::filesystem::directory_iterator iterator(string("."));

     

      for(; iterator != boost::filesystem::directory_iterator(); ++iterator)

            {

                  cout << (iterator->path().filename())<< endl;

                  listOfFiles.push_back(iterator->path().filename()

                 );

        }

 

 

error: error C2440: 'initializing' : cannot convert from 'boost::filesystem3::path' to 'std::basic_string<_Elem,_Traits,_Ax>'

 



Thanks in advance.

aman

Always have your stuff when you need it with @Dropbox. 2GB account is free! http://db.tt/xOEJ2Ag

 


_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users