Uri Constructor (String^)
Initializes a new instance of the Uri class with the specified URI.
Assembly: System (in System.dll)
| Exception | Condition | ||
|---|---|---|---|
| ArgumentNullException | uriString is null. | ||
| UriFormatException |
uriString is empty. -or- The scheme specified in uriString is not correctly formed. See CheckSchemeName. -or- uriString contains too many slashes. -or- The password specified in uriString is not valid. -or- The host name specified in uriString is not valid. -or- The file name specified in uriString is not valid. -or- The user name specified in uriString is not valid. -or- The host or authority name specified in uriString cannot be terminated by backslashes. -or- The port number specified in uriString is not valid or cannot be parsed. -or- The length of uriString exceeds 65519 characters. -or- The length of the scheme specified in uriString exceeds 1023 characters. -or- There is an invalid character sequence in uriString. -or- The MS-DOS path specified in uriString must start with c:\\. |
This constructor creates a Uri instance from a URI string. It parses the URI, puts it in canonical format, and makes any required escape encodings.
This constructor does not ensure that the Uri refers to an accessible resource.
This constructor assumes that the string parameter references an absolute URI and is equivalent to calling the Uri constructor with UriKind set to Absolute. If the string parameter passed to the constructor is a relative URI, this constructor will throw a UriFormatException.
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Silverlight
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
