PackUriHelper.GetRelativeUri(Uri, Uri) 方法

定义

返回两个指定的 PackagePart URI 之间的相对 URI。Returns the relative URI between two specified PackagePart URIs.

public:
 static Uri ^ GetRelativeUri(Uri ^ sourcePartUri, Uri ^ targetPartUri);
public static Uri GetRelativeUri (Uri sourcePartUri, Uri targetPartUri);
static member GetRelativeUri : Uri * Uri -> Uri
Public Shared Function GetRelativeUri (sourcePartUri As Uri, targetPartUri As Uri) As Uri

参数

sourcePartUri
Uri

源部件的 URI。The URI of the source part.

targetPartUri
Uri

目标部件的 URI。The URI of the target part.

返回

Uri

sourcePartUritargetPartUri 的相对 URI。The relative URI from sourcePartUri to targetPartUri.

例外

sourcePartUritargetPartUrinullsourcePartUri or targetPartUri is null.

sourcePartUritargetPartUri 没有有效的 Uri 语法。Either the sourcePartUri or targetPartUri does not have a valid Uri syntax.

注解

下表说明了的示例事例 GetRelativeUriThe following table illustrates sample cases for GetRelativeUri.

sourcePartUri targetPartUri 返回的相对 URIReturned relative URI
/mydoc/markup/page.xml/mydoc/markup/page.xml /mydoc/markup/picture.jpg/mydoc/markup/picture.jpg picture.jpgpicture.jpg
/mydoc/markup/page.xml/mydoc/markup/page.xml /mydoc/picture.jpg/mydoc/picture.jpg ../picture.jpg../picture.jpg
/mydoc/markup/page.xml/mydoc/markup/page.xml /mydoc/images/picture.jpg/mydoc/images/picture.jpg ../images/picture.jpg../images/picture.jpg

适用于

另请参阅