C# Using Substring, how do I extract this string?
c#, substring
Solution
If you're getting a Uri, why not just do uri.Segments[0]?
Or even `path.Split(new Char[] { '/' })[1]` ?
Problem
I want to extract the first folder in the URL below, in this example it is called 'extractThisFolderName' but the folder could have any name and be any length. With this in mind how can I use substring to extract the first folder name? The string: www.somewebsite.com/extractThisFolderName/leave/this/behind ``` String folderName = path.Substring(path.IndexOf(@"/"),XXXXXXXXXXX); ``` It's the length I'm struggling with.