Share via


IPath.Relativize(IPath) Method

Definition

Constructs a relative path between this path and a given path.

[Android.Runtime.Register("relativize", "(Ljava/nio/file/Path;)Ljava/nio/file/Path;", "GetRelativize_Ljava_nio_file_Path_Handler:Java.Nio.FileNio.IPathInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)]
public Java.Nio.FileNio.IPath? Relativize (Java.Nio.FileNio.IPath? other);
[<Android.Runtime.Register("relativize", "(Ljava/nio/file/Path;)Ljava/nio/file/Path;", "GetRelativize_Ljava_nio_file_Path_Handler:Java.Nio.FileNio.IPathInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", ApiSince=26)>]
abstract member Relativize : Java.Nio.FileNio.IPath -> Java.Nio.FileNio.IPath

Parameters

other
IPath

the path to relativize against this path

Returns

the resulting relative path, or an empty path if both paths are equal

Attributes

Remarks

Constructs a relative path between this path and a given path.

Relativization is the inverse of #resolve(Path) resolution. This method attempts to construct a #isAbsolute relative path that when #resolve(Path) resolved against this path, yields a path that locates the same file as the given path. For example, on UNIX, if this path is "/a/b" and the given path is "/a/b/c/d" then the resulting relative path would be "c/d". Where this path and the given path do not have a #getRoot root component, then a relative path can be constructed. A relative path cannot be constructed if only one of the paths have a root component. Where both paths have a root component then it is implementation dependent if a relative path can be constructed. If this path and the given path are #equals equal then an empty path is returned.

For any two #normalize normalized paths p and q, where q does not have a root component, <blockquote> p.relativize(p.resolve(q)).equals(q)</blockquote>

When symbolic links are supported, then whether the resulting path, when resolved against this path, yields a path that can be used to locate the Files#isSameFile same file as other is implementation dependent. For example, if this path is "/a/b" and the given path is "/a/x" then the resulting relative path may be "../x". If "b" is a symbolic link then is implementation dependent if "a/b/../x" would locate the same file as "/a/x".

Java documentation for java.nio.file.Path.relativize(java.nio.file.Path).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to