本文整理汇总了C#中IAbsoluteDirectoryPath.OnSameVolumeThan方法的典型用法代码示例。如果您正苦于以下问题:C# IAbsoluteDirectoryPath.OnSameVolumeThan方法的具体用法?C# IAbsoluteDirectoryPath.OnSameVolumeThan怎么用?C# IAbsoluteDirectoryPath.OnSameVolumeThan使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IAbsoluteDirectoryPath
的用法示例。
在下文中一共展示了IAbsoluteDirectoryPath.OnSameVolumeThan方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TryGetRelativePath
//
// Relative/absolute computation
//
internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string pathResult, out string failurereason) {
Debug.Assert(pathFrom != null);
Debug.Assert(pathTo != null);
if (!pathFrom.OnSameVolumeThan(pathTo)) {
failurereason = @"Cannot compute relative path from 2 paths that are not on the same volume
PathFrom = """ + pathFrom.ToString() + @"""
PathTo = """ + pathTo.ToString() + @"""";
pathResult = null;
return false;
}
// Only work with Directory
if (pathTo.IsFilePath) { pathTo = pathTo.ParentDirectoryPath; }
pathResult = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
failurereason = null;
return true;
}
示例2: TryGetRelativePath
internal static bool TryGetRelativePath(IAbsoluteDirectoryPath pathFrom, IAbsolutePath pathTo, out string relativePath, out string failureMessage)
{
//Argument.IsNotNull(nameof(pathFrom), pathFrom);
//Argument.IsNotNull(nameof(pathTo), pathTo);
if (!pathFrom.OnSameVolumeThan(pathTo))
{
failureMessage = @"Cannot compute relative path from 2 paths that are not on the same volume
PathFrom = """ + pathFrom + @"""
PathTo = """ + pathTo + @"""";
relativePath = null;
return false;
}
// Only work with Directory
if (pathTo.IsFilePath)
{
pathTo = pathTo.ParentDirectoryPath;
}
relativePath = GetPathRelativeTo(pathFrom.ToString(), pathTo.ToString());
failureMessage = null;
return true;
}