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
?
Asked
Active
Viewed 9,925 times
24

Glenn Slaven
- 33,720
- 26
- 113
- 165
-
1Duplicate of http://stackoverflow.com/questions/372865/path-combine-for-urls. – Mike Jul 13 '11 at 01:49
-
2No, I know how to combine urls, I'm trying to avoid hard coding the '/' into my code – Glenn Slaven Jul 13 '11 at 02:19
1 Answers
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
-
1I 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