Click here to Skip to main content
15,887,373 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi All!

I have one problem, please suggest.
C++
CString str = _T("CodeProject\Application");

int l_Temp = str.FindOneOf(_T("/\?<>|:*")); //I'm searching for all these characters

if(l_Temp != -1)
{
  AfxMessageBox(_T("Invalid Name"));
}

It is able to searching all characters, but '\' is not searching.

Please do the needful.

Thanks
Sam
Posted
Updated 26-Feb-13 1:45am
v2
Comments
Philippe Mori 27-Feb-13 19:21pm    
By the way, you should also have a double backslash in CodeProject\\Application.

The backslash (\) must be followed with a second backslash (\\) when it appears within a string, see Escape Sequences[^]

In your case there need to be three backslash in the string, two for the backslash itself and one for the question mark (?).
C++
int l_Temp = str.FindOneOf(_T("/\\\?<>|:*"));
 
Share this answer
 
Comments
Mr Sam 26-Feb-13 9:33am    
Thank You so much! my problem got solved :-)
nv3 26-Feb-13 9:51am    
Then please click Accept on the solution that has helped you ;-)
Mr Sam 27-Feb-13 7:16am    
Oh! Sorry, i forgot. Thank you!
use '\\' not '\'
ex:-
if(csProfilename.FindOneOf(L"\\/:?<>\"|")!=-1)
 
Share this answer
 
Comments
Mr Sam 27-Feb-13 7:17am    
Thank you!
use '\\' instead of '\'

:) happy to help
 
Share this answer
 
Comments
Mr Sam 27-Feb-13 7:17am    
Thank You!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900