On Thu, Apr 24, 2008 at 5:01 PM, Mika Fischer <mika.fischer@zoopnet.de> wrote:
Robert Dailey schrieb:
> boost::filesystem::path myPath( "C:/somefolder/somefile" );I think you basically have the option of doing:
> myPath += ".txt";
>
> Notice the 2nd line of code. This isn't legal. What is the cleanest way
> to append an extension to a file path? I don't think /= will work; if I
> remember correctly it will add "/.txt".
1)
myPath = myPath.branch_path() / (myPath.leaf() + ".txt");
2)
string tmp = p.leaf();
p.remove_leaf();
p /= tmp + ".txt";
Both are not really pretty...
Regards,
Mika