just get filename from wstring?
Hello,
I have a file path in a wstring like this:
wstring pathName = L"c:\windows\system\test.exe";
I want to be able to geta new wstring that just contains "test" from this wstring.
How can I do that? Can someone provide example code?
Regards,
Ellay K.
Re: just get filename from wstring?
Quote:
Originally Posted by
ekhule
Hello,
I have a file path in a wstring like this:
wstring pathName = L"c:\windows\system\test.exe";
I want to be able to geta new wstring that just contains "test" from this wstring.
How can I do that? Can someone provide example code?
Regards,
Ellay K.
If you are using Windows, use the _tsplitpath function.
Regards,
Paul McKenzie
Re: just get filename from wstring?
Just iterate the string backwards till you find a slash, then iterate forwards saving the characters till you find a . What's the problem?
Re: just get filename from wstring?
Hello Paul,
Do you have any sample code with that function? I can't much about it online.
Regards,
Ellay K.
Re: just get filename from wstring?
Quote:
Originally Posted by
ekhule
Hello Paul,
Do you have any sample code with that function? I can't much about it online.
Regards,
Ellay K.
_splitpath
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
Re: just get filename from wstring?
Quote:
Originally Posted by
ekhule
Hello Paul,
Do you have any sample code with that function? I can't much about it online.
Regards,
Ellay K.
If you are only using wide chars, then _wsplitpath is the function.
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
http://msdn.microsoft.com/en-us/libr...=vs.80%29.aspx
Regards,
Paul McKenzie