I have a .NET 3.5 web application written in C # that does some URL processing, including the file path, and I am having a problem. When I call string.Split('/'), it matches the characters "/" and "\". Is this ... supposed to happen? I assumed that he would have noticed that the ASCII values were different and missed it, but it seems like I'm wrong.
string[] buffer = url.Split('/');
The above code gives string[]with 6 elements in it ... which seems counter intuitive. Is there a way to make it Split()fit ONLY with a slash? I'm lucky now, since the offensive slashes are at the end of the URL, I can just concatenate the rest of the elements in string[], but this is a lot of work for what we are doing, and not a great solution to the main problem.
Has anyone come across this before? Simple answer? I appreciate it!
Details Code:
url = HttpContext.Current.Request.Path.Replace("http://", "");
string[] buffer = url.Split('/');
It turns out that Request.Path and Request.RawUrl are changing my slashes, which is ridiculous. So, the time to explore this is a little more and figure out how to get the URL from a function that doesn't break my formatting. Thanks everyone for playing along with my insanity, sorry, that was a misleading question!