EN
Este conteúdo não está disponível em seu idioma, mas aqui está a versão em inglês.

Uri class

Applies to Windows and Windows Phone

Parses Uniform Resource Identifiers (URIs).

.NET:  This type appears as System.Uri for all Windows Runtime programming when writing code in C# or Visual Basic. The available members of System.Uri are different. See System.Uri.

Syntax


var uri = new Windows.Foundation.Uri(string);
var uri = new Windows.Foundation.Uri(string, string);

Attributes

[DualApiPartition()]
[MarshalingBehavior(Agile)]
[Threading(Both)]
[Version(0x06020000)]

Members

The Uri class has these types of members:

Constructors

The Uri class has these constructors.

ConstructorDescription
Uri(String) Creates a Uniform Resource Identifier (URI) from the specified string.
Uri(String,String) Creates a Uniform Resource Identifier (URI) by combining a base Uniform Resource Identifier (URI) and a relative Uniform Resource Identifier (URI).

 

Methods

The Uri class has these methods. With C#, Visual Basic, and C++, it also inherits methods from the Object class.

MethodDescription
CombineUri Adds the specified Uniform Resource Identifier (URI) to the current Uniform Resource Identifier (URI).
Equals Determines whether the specified Uniform Resource Identifier (URI) is equal to the current Uniform Resource Identifier (URI).
EscapeComponent Converts a URI string to its escaped representation.
ToString Gets a canonical string representation for the current Uri.
UnescapeComponent Converts the specified string by replacing any escape sequences with their unescaped representation.

 

Properties

The Uri class has these properties.

PropertyAccess typeDescription

AbsoluteCanonicalUri

Read-onlyGets a fully canonicalized RFC-complaint representation of the current URI.

AbsoluteUri

Read-onlyGets the entire, non-canonical IRI.

DisplayIri

Read-onlyGets the decoded unicode characters that make up the current URI.

DisplayUri

Read-onlyGets a representation of the IRI that can be used for display purposes.

Domain

Read-onlyGets the domain name, including top-level domain, from a Uniform Resource Identifier (URI).

Extension

Read-onlyGets the file name extension of the resource that is referenced in the Uniform Resource Identifier (URI).

Fragment

Read-onlyGets the text following a fragment marker (#), including the fragment marker itself.

Host

Read-onlyGets the fully qualified domain name.

Password

Read-onlyGets the password, as parsed from a Uniform Resource Identifier (URI).

Path

Read-onlyGets the path and resource name.

Port

Read-onlyGets the port number.

Query

Read-onlyGets the query string.

QueryParsed

Read-onlyGets a parsed URL query string.

RawUri

Read-onlyGets the entire original Uniform Resource Identifier (URI) string.

SchemeName

Read-onlyGets the protocol scheme name.

Suspicious

Read-onlyGets a value that indicates whether the Uniform Resource Identifier (URI) is not well-formed.

UserName

Read-onlyGets the user name as parsed from a Uniform Resource Identifier (URI).

 

Remarks

When building Windows Runtime apps with the Microsoft .NET Framework, this class is hidden and developers should use the System.Uri class, which uses RFC 3987 to encode and decode URIs. The Uri class doesn't percent-encode non-ASCII characters in file:// URIs and interprets percent-encoding using the user's current codepage.

Here is a breakdown of the parts of an example URI:

scheme://username:password@host:port/path.extension?query#fragment

For example:

ftp://user:password@ftp.microsoft.com:8080/path/bin/file.asp?q=query#fragment

In this example:

  • scheme is ftp
  • host is ftp.microsoft.com
  • domain is microsoft.com (a subset of host)
  • port is 8080
  • extension is asp

Examples

This example creates a URI that uses the http protocol to access a website.


// The URI string
var uriToLaunch = "http://www.bing.com";

// Create a Uri object from the URI string 
var uri = new Windows.Foundation.Uri(uriToLaunch);

This example creates a URI that uses the ms-appx protocol to access an image file in the app package.


// The URI string
var uriImage = "ms-appx:///images/SecondaryTileDefault-sdk.png";

// Create a Uri object from the URI string
var uri = new Windows.Foundation.Uri(uriImage);

This example creates a URI that uses the ms-appdata protocol to access a file in local app data store for your app.


// The URI string
var uriFile = "ms-appdata:///local/file.ext";

// Create a Uri object from the URI string
var uri = new Windows.Foundation.Uri(uriFile);

Requirements

Minimum supported client

Windows 8 [Windows Store apps, desktop apps]

Minimum supported server

Windows Server 2012 [Windows Store apps, desktop apps]

Minimum supported phone

Windows Phone 8

Namespace

Windows.Foundation
Windows::Foundation [C++]

Metadata

Windows.winmd

See also

System.Uri
How to reference content (HTML)
How to load file resources (XAML)
Connecting to networks and web services
WwwFormUrlDecoder

 

 

Mostrar:
© 2014 Microsoft