Jimmu John Jimmu John - 3 months ago 7
Vb.net Question

How to return a string in between these "\" characters?

I have a string path that is "C:\folder\theStringIWant\anotherfolder"

I want to extract the string "theStringIWant" from that string, how would i do that?

Answer
@"C:\folder\theStringIWant\anotherfolder".Split('\\')[2]

Or

DirectoryInfo d = new DirectoryInfo(@"C:\folder\theStringIWant\anotherfolder");
var whatYouWant = d.Parent;
Comments