Export (0) Print
Expand All

Uri.GetLeftPart Method

Gets the specified portion of a Uri instance.

Namespace:  System
Assembly:  System (in System.dll)

member GetLeftPart : 
        part:UriPartial -> string

Parameters

part
Type: System.UriPartial

One of the UriPartial values that specifies the end of the URI portion to return.

Return Value

Type: System.String
A String that contains the specified portion of the Uri instance.

ExceptionCondition
InvalidOperationException

The current Uri instance is not an absolute instance.

ArgumentException

The specified part is not valid.

The GetLeftPart method returns a string containing the leftmost portion of the URI string, ending with the portion specified by part.

GetLeftPart includes delimiters in the following cases:

  • Scheme includes the scheme delimiter.

  • Authority does not include the path delimiter.

  • Path includes any delimiters in the original URI up to the query or fragment delimiter.

  • Query includes the Path, plus the query and its delimiter.

The following examples show a URI and the results of calling GetLeftPart with Scheme, Authority, Path, or Query.

URI

Scheme

Authority

Path

Query

http://www.contoso.com/index.htm?date=today

http://

http://www.contoso.com

http://www.contoso.com/index.htm

http://www.contoso.com/index.htm?date=today

http://www.contoso.com/index.htm#main

http://

http://www.contoso.com

http://www.contoso.com/index.htm

http://www.contoso.com/index.htm

mailto:user@contoso.com?subject=uri

mailto:

mailto:user@contoso.com

mailto:user@contoso.com?subject=uri

<none>

nntp://news.contoso.com/123456@contoso.com

nntp://

nntp://news.contoso.com

nntp://news.contoso.com/123456@contoso.com

nntp://news.contoso.com/123456@contoso.com

news:123456@contoso.com

news:

news:123456@contoso.com

news:123456@contoso.com

<none>

file://server/filename.ext

file://

file://server

file://server/filename.ext

file://server/filename.ext

The following example creates a Uri instance and writes the path to the console.

No code example is currently available or this language may not be supported.

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft