0

I have a given LPCWSTR variable, which holds a full path.

I want to extract from it only the file name.

Any suggestions how can I manipulate the LPCWSTR to achieve that?

In addition - How can I get the char in a specific index of the LPCWSTR?

Thank you.

rrrrr
  • 47
  • 5

1 Answers1

2

The windows function PathStripPath will do what you want. Since you have a Unicode string you'll want to call the "W" version PathStripPathW.

JJF
  • 2,681
  • 2
  • 18
  • 31
  • 1
    Also see [`PathFindFileName()`](https://msdn.microsoft.com/en-us/library/windows/desktop/bb773589.aspx). `PathStripPath()` modifies the buffer passed to it. `PathFindFileName()` returns a pointer to the filename within the buffer without modifying the buffer itself. – Remy Lebeau Apr 18 '16 at 19:57