Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

PackUriHelper.CreatePartUri Method

Creates a formatted PackagePart URI.

Namespace: System.IO.Packaging
Assembly: WindowsBase (in windowsbase.dll)

public static Uri CreatePartUri (
	Uri partUri
)
public static Uri CreatePartUri (
	Uri partUri
)
public static function CreatePartUri (
	partUri : Uri
) : Uri
You cannot use methods in XAML.

Parameters

partUri

The URI of the PackagePart within the package.

Return Value

A formatted PackagePart URI.

The URI of a PackagePart is always referenced from the Package root.

The returned PackagePart URI is an absolute path that always starts with "/" and conforms to the syntax defined in the Open Packaging Conventions Specification.

The following table illustrates sample cases for CreatePartUri:

 partUri

 Returned Part URI 

 picture1.jpg 

 /picture1.jpg 

 /picture2.jpg 

 /picture2.jpg 

 a/mydoc.xaml 

 /a/mydoc.xaml 

 /b/bar.xaml 

 /b/bar.xaml 

The following example shows how to use the CreatePartUri method to define relative URIs for PackagePart elements.

// 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));

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0

Community Additions

Show: