CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2
  1. #1
    Join Date
    Mar 2008
    Posts
    18

    Cut String Position

    Hi All

    I want to cut string.String is "C:\\Abc\\ad\\ta.txt" and i want to cut these \\ad\\ta.txt. And new string like this C:\\Abc.

    I want to cut String After Directory and first file or Folder.I am useing this code.
    Code:
    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);
    Plz help me

  2. #2
    Join Date
    Oct 2002
    Location
    Timisoara, Romania
    Posts
    14,360

    Re: Cut String Position

    And what is the actual problem? You should repeat that operation twice, if you want to remove C:\\abc, not just C:\\.
    Marius Bancila
    Home Page
    My CodeGuru articles

    I do not offer technical support via PM or e-mail. Please use vbBulletin codes.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured