in simpleProviderManaged/FileSystemApi.cs [247:275]
public static string TryGetPathRelativeToRoot(string root, string path, bool isPathToADirectory)
{
const Int32 MaxPath = 260;
StringBuilder relativePathBuilder = new StringBuilder(MaxPath);
string pathFrom;
if (!root.EndsWith(Path.DirectorySeparatorChar.ToString()))
{
// PathRelativePathToW expects the root to have a trailing slash.
pathFrom = root + Path.DirectorySeparatorChar;
}
else
{
pathFrom = root;
}
bool result = PathRelativePathToW(relativePathBuilder,
pathFrom,
FileFlagsAndAttributes.FileAttributeDirectory,
path,
isPathToADirectory ? FileFlagsAndAttributes.FileAttributeDirectory : FileFlagsAndAttributes.FileAttributeNormal);
if (!result)
{
throw new Exception($"Failed to get relative path of {path} with root {root}.");
}
return relativePathBuilder.ToString();
}