PackUriHelper.CreatePartUri(Uri) Method
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Creates a formatted 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
Parameters
- partUri
- Uri
The URI of the PackagePart within the package.
Returns
A formatted PackagePart URI.
Exceptions
partUri
is null
.
partUri
is not an absolute Uri.
Examples
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));
' 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))
Remarks
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 |
Applies to
See also
.NET
피드백
https://aka.ms/ContentUserFeedback
출시 예정: 2024년 내내 콘텐츠에 대한 피드백 메커니즘으로 GitHub 문제를 단계적으로 폐지하고 이를 새로운 피드백 시스템으로 바꿀 예정입니다. 자세한 내용은 다음을 참조하세요.다음에 대한 사용자 의견 제출 및 보기