-
June 15th, 2012, 08:41 AM
#1
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.
-
June 15th, 2012, 08:57 AM
#2
Re: just get filename from wstring?
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
-
June 15th, 2012, 09:59 AM
#3
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?
-
June 15th, 2012, 10:05 AM
#4
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.
-
June 15th, 2012, 10:07 AM
#5
Re: just get filename from wstring?
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
-
June 15th, 2012, 10:10 AM
#6
Re: just get filename from wstring?
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|