Directory.ResolveLinkTarget(String, Boolean) Method

Definition

Gets the target of the specified directory link.

C#
public static System.IO.FileSystemInfo? ResolveLinkTarget (string linkPath, bool returnFinalTarget);

Parameters

linkPath
String

The path of the directory link.

returnFinalTarget
Boolean

true to follow links to the final target; false to return the immediate next link.

Returns

A DirectoryInfo instance if linkPath exists, independently if the target exists or not. null if linkPath is not a link.

Exceptions

The directory on linkPath does not exist.

-or-

There are too many levels of symbolic links.

Remarks

When returnFinalTarget is true, the maximum number of symbolic links that are followed are 40 on Unix and 63 on Windows.

Symbolic links and junctions are the types of links this API can resolve.

Applies to

Product Versions
.NET 6, 7, 8, 9

See also