Description
Originally reported by @fitdev in #57575
On Windows, there is an inconsistency of final targets returned depending on which APIs are used, and whether or not virtual drives created with subst command are used in the path (both the link and the target residing on such virtual drives):
The DirectoryInfo.ResolveLinkTarget(returnFinalTarget: true)
API (and other APIs you added that resolve final target) resolve the final target to non-virtual drives, while the DirectoryInfo.LinkTarget
(and other similar APIs that resolve the immediate target), when called repeatedly while LinkTarget != null stop at the virtual drive level.
So, given a structure like this:
C:\RootDirectoryForVirtualDriveX
X:\SomeRealFolder
X:\SymlinkToRealFolderOnX -> X:\SomeRealFolder
Calling DirectoryInfo.ResolveLinkTarget(returnFinalTarget: true)
on X:\SymlinkToRealFolderOnX
will result in: C:\RootDirectoryForVirtualDriveX\SomeRealFolder
While calling DirectoryInfo.LinkTarget
(repeatedly while the result is non-null) on X:\SymlinkToRealFolderOnX
will result in: X:\SomeRealFolder
Even though, logically, and for consistency results should be the same.