Click here to Skip to main content
15,891,864 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi,

I need to get the bold substring from this path.

C:\\Workspaces\\thisRequired\\Di\\DiDe\\bin\\Debug

How can I get this?
Posted
Comments
Sergey Alexandrovich Kryukov 28-Feb-14 10:00am    
Why?
—SA

Easiest way?
C#
string path = "C:\\Workspaces\\thisRequired\\Di\\DiDe\\bin\\Debug";
string[] parts = path.Split('\\');
if (parts.Length >= 3)
    {
    Console.WriteLine(parts[2]);
    }
 
Share this answer
 
Comments
Member 10304617 28-Feb-14 9:47am    
thanks
OriginalGriff 28-Feb-14 10:27am    
You're welcome!
Member 10304617 3-Mar-14 11:05am    
Do you know to tell me how can I get the name of the user that is connect now to Team Foundation Server in Visual Studio?
You can either use the Split[^] function to chop the whole path string up into the substrings between "\\", or you can use the IndexOf[^] and Substring[^] functions to find it and extract it.
 
Share this answer
 
Comments
Member 10304617 28-Feb-14 9:47am    
thanks.

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