BCS
BCS

Reputation: 78536

Most general way to make a Uri object?

I need to convert all of the following forms into .NET Uri object:

I have already checked an new Uri("..\somthing\something") and new Uri("../something/somthing/else") don't work. Also none Uri's statics seem to be for this.

Any ideas beside a big logic tree and/or regex?

Upvotes: 2

Views: 167

Answers (1)

JaredPar
JaredPar

Reputation: 754665

Try the following

new Uri("../whatever",UriKind.RelativeOrAbsolute);

Without the RelativeOrAbsolute flag the Uri will attempt to parse a complete absolute URI. Adding the flag will let it parse essentially any valid URI (relative or absolute)

Upvotes: 4

Related Questions