24

I need to build up a URI path from string values and I'm combining them together. Is there a URI constant for the / separator value as there is for Path.PathSeparator?

Glenn Slaven
  • 33,720
  • 26
  • 113
  • 165

1 Answers1

12

Apparently there isn't. It's not platform-specific after all and RFC 2396 RFC 3986 specifies that the path separator in URIs is in fact /.

For combining URIs it's probably best to use the Uri(baseUrl, relativeUrl) constructor as suggested in Mike's comment.

Community
  • 1
  • 1
Stefan Dragnev
  • 14,143
  • 6
  • 48
  • 52
  • 1
    I believe RFC 2396 has been obsoleted by [RFC 3986](https://tools.ietf.org/html/rfc3986) – Andacious Oct 03 '16 at 20:17
  • there is some platform specific code in the [current implementation of the .NET framework](https://referencesource.microsoft.com/#System/net/System/URI.cs,3619), but that deals with special cases of the file:// protocol where there can be UNC paths... otherwise, there is the char literal `'/'` all over the place, so if they had defined a constant somewhere, they don't use it. – Cee McSharpface Jun 29 '17 at 17:54