String Problem
C / C++ / MFC
41
Posts
13
Posters
0
Views
1
Watching
-
I am useing this.
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");int nPos = FullPath.Find( \_T('\\\\') ); if( nPos >= 0 ) { DirPath = FullPath.Mid( 0, nPos); } AfxMessageBox(DirPath);
Then i am geting out put C: But i need to C:\abc. Plz tell me what i use. Thanks in advance
Use ReverseFind() instead of Find().
CString DirPath;
CString FullPath = _T("C:\\abc\\cd\\as.txt");
int nPos = FullPath.ReverseFind( _T('\\') );
if( nPos >= 0 )
{
DirPath = FullPath.Mid( 0, nPos);
}
AfxMessageBox(DirPath);