You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You're right, it does behave differently. I based the behavior off of Python's pathlib library which does throw an error, so I guess that's where the difference comes from.
>>> import pathlib
>>> p1 = pathlib.PurePath('E:/a')
>>> p2 = pathlib.PurePath('E:/a/b')
>>> p1.relative_to(p2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/pathlib.py", line 682, in relative_to
raise ValueError(f"{str(self)!r} is not in the subpath of {str(other)!r}")
ValueError: 'E:/a' is not in the subpath of 'E:/a/b'
In
System.IO
,Path.GetRelativePath(pathstr1, pathstr2)
doesn't require that pathstr2 is inside pathstr1However, In
PathLib
, runningpath2.RelativeTo(path1)
when path2 isn't inside path1 will throw an error:The text was updated successfully, but these errors were encountered: