title: C# string.Split() Matching Both Slashes?
body: <p>I've got a .NET 3.5 web application written in C# doing some URL rewriting that includes a file path, and I'm running into a problem. When I call <code>string.Split('/')</code> it matches both '/' and '\' characters. Is that... supposed to happen? I assumed that it would notice that the ASCII values were different and skip it, but it appears that I'm wrong.</p>
  
  <pre><code>// url = 'someserver.com/user/token/files\subdir\file.jpg
  string[] buffer = url.Split('/');
  </code></pre>
  
  <p>The above code gives a <code>string[]</code> with 6 elements in it... which seems counter intuitive. Is there a way to force <code>Split()</code> to match ONLY the forward slash? Right now I'm lucky, since the offending slashes are at the end of the URL, I can just concatenate the rest of the elements in the <code>string[]</code>, but it's a lot of work for what we're doing, and not a great solution to the underlying problem.</p>
  
  <p>Anyone run into this before? Have a simple answer? I appreciate it!</p>
  
  <p>More Code:</p>
  
  <pre><code>url = HttpContext.Current.Request.Path.Replace("http://", "");
  string[] buffer = url.Split('/');
  </code></pre>
  
  <p><strong>Turns out, Request.Path and Request.RawUrl are both changing my slashes, which is ridiculous. So, time to research that a bit 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 it was a misleading question!</strong></p>