# How to get the file extension using boost filesystem

This topic is 2412 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

[font=arial,helvetica,sans-serif]Hello I've just finally figured out how to use and install boost.

I'm able to

1.Check the contents of a folder aka 'directory'

2.Check if a file is a directory or not,

3.Check if a file is a regular file

4.Check if a file exists[/font]

[font=arial,helvetica,sans-serif]But how do I check what file extension my contents of a directory has for example

if I had a folder called

folder1

inside folder1 would be three files.

mymum.txt
mygranny.max

each file with its own extension like so

.txt
.vim
.max

how would I in boost check folder1 for its contents and then check what file extensions each file has and then do something like cout the extension

cout << extension << endl;

using boost filesystem

thanks for any advice or ideas you may have it has tooken me a while to figure out how to use boost but I finally figured it out you don't use bootstrap.bat but build.bat to get bjam [/font]

##### Share on other sites
You would probably want to use the extension() function with path objects.

##### Share on other sites
do you have reference or example of that in use to link too? that would help me greatly thanks

##### Share on other sites
Okay I've figured out how to do that now I just need to make this work

 if(p.extension().string() == ".txt") { cout << "Hello" << endl; } 

1. 1
Rutin
37
2. 2
3. 3
4. 4
5. 5

• 12
• 10
• 13
• 104
• 11
• ### Forum Statistics

• Total Topics
632982
• Total Posts
3009689
• ### Who's Online (See full list)

There are no registered users currently online

×