Share via


PackUriHelper.CreatePartUri(Uri) Methode

Definition

Erstellt einen formatierten PackagePart-URI.

public:
 static Uri ^ CreatePartUri(Uri ^ partUri);
public static Uri CreatePartUri (Uri partUri);
static member CreatePartUri : Uri -> Uri
Public Shared Function CreatePartUri (partUri As Uri) As Uri

Parameter

partUri
Uri

Der URI des PackagePart im Paket.

Gibt zurück

Uri

Ein formatierter PackagePart-URI.

Ausnahmen

partUri ist null.

partUri ist kein absoluter Uri.

Beispiele

Im folgenden Beispiel wird gezeigt, wie die CreatePartUri -Methode verwendet wird, um relative URIs für PackagePart Elemente zu definieren.

// Convert system path and file names to Part URIs. In this example
// Uri partUriDocument /* /Content/Document.xml */ =
//     PackUriHelper.CreatePartUri(
//         new Uri("Content\Document.xml", UriKind.Relative));
// Uri partUriResource /* /Resources/Image1.jpg */ =
//     PackUriHelper.CreatePartUri(
//         new Uri("Resources\Image1.jpg", UriKind.Relative));
Uri partUriDocument = PackUriHelper.CreatePartUri(
                          new Uri(documentPath, UriKind.Relative));
Uri partUriResource = PackUriHelper.CreatePartUri(
                          new Uri(resourcePath, UriKind.Relative));
' Convert system path and file names to Part URIs. In this example
' Dim partUriDocument as Uri /* /Content/Document.xml */ =
'     PackUriHelper.CreatePartUri(
'         New Uri("Content\Document.xml", UriKind.Relative))
' Dim partUriResource as Uri /* /Resources/Image1.jpg */ =
'     PackUriHelper.CreatePartUri(
'         New Uri("Resources\Image1.jpg", UriKind.Relative))
Dim partUriDocument As Uri = PackUriHelper.CreatePartUri(New Uri(documentPath, UriKind.Relative))
Dim partUriResource As Uri = PackUriHelper.CreatePartUri(New Uri(resourcePath, UriKind.Relative))

Hinweise

Auf den URI eines PackagePart wird immer vom Package Stamm verwiesen.

Der zurückgegebene PackagePart URI ist ein absoluter Pfad, der immer mit "/" beginnt und der in der Spezifikation für Open Packaging Conventions definierten Syntax entspricht.

In der folgenden Tabelle werden Beispielfälle für CreatePartUriveranschaulicht.

partUri Zurückgegebener Part-URI
picture1.jpg /picture1.jpg
/picture2.jpg /picture2.jpg
a/mydoc.xaml /a/mydoc.xaml
/b/bar.xaml /b/bar.xaml

Gilt für:

Weitere Informationen