Archived

This topic is now archived and is closed to further replies.

peter86

Take out the filename of a path

Recommended Posts

peter86    123
If I have this path: "C:\Temp\test.txt", then I want to separate the path in two strings, "C:\Temp\" and "test.txt". I have the path i a WCHAR. So how do I code this?

Share this post


Link to post
Share on other sites
Cedric    158
You can do it with the STL, but I''m not very good with those things. You could std::reverse the sequence, std::find the first "\\" in the reversed sequence, and use std::string::substr with string::size - n to get the path.

If someone knows how to get rid of the ugliness and the inefficiency with standard algorithms or with boost, I''d be interested to know it.

Cédric

Share this post


Link to post
Share on other sites