本文整理汇总了C#中RelativePath.ToFullPath方法的典型用法代码示例。如果您正苦于以下问题:C# RelativePath.ToFullPath方法的具体用法?C# RelativePath.ToFullPath怎么用?C# RelativePath.ToFullPath使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RelativePath
的用法示例。
在下文中一共展示了RelativePath.ToFullPath方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TestPaths
public void TestPaths()
{
FullPath root;
FullPath full;
RelativePath rel;
string str1, str2;
string[,] cases =
{
// root: // full: // full canonical: // relative canonical:
{ @"C:\a/b/c/", @"D:\a/b/", @"D:\a\b\", @"D:\a\b\" },
{ @"C:\a\b\c", @"C:\a\b\c", @"C:\a\b\c", @"" },
{ @"C:\a\b\c", @"C:\a\b\c\", @"C:\a\b\c\", @"" },
{ @"C:\a\b\c\", @"C:\a\b\c", @"C:\a\b\c", @"" },
{ @"C:\a\b\c\", @"C:\a\b\c\", @"C:\a\b\c\", @"" },
{ @"C:\a\b\c", @"C:\a\b", @"C:\a\b", @".." },
{ @"C:\a\b\c\", @"C:\a\b", @"C:\a\b", @".." },
{ @"C:\a\b\c", @"C:\", @"C:\", @"..\..\.." },
{ @"C:\a\b\c\", @"C:\", @"C:\", @"..\..\.." },
{ @"C:\a\b\c\", @"C:\a\b\x\y\z", @"C:\a\b\x\y\z", @"..\x\y\z" },
{ @"C:\a\b\cd\", @"C:\a\b\c", @"C:\a\b\c", @"..\c" },
{ @"C:\a\b\cd", @"C:\a\b\c", @"C:\a\b\c", @"..\c" },
{ @"C:\a\b\cd\", @"C:\a\b\c\d", @"C:\a\b\c\d", @"..\c\d" },
{ @"C:\a\b\cd", @"C:\a\b\c\d", @"C:\a\b\c\d", @"..\c\d" },
};
for (int i = 0; i < cases.GetLength(0); i++)
{
root = new FullPath(cases[i, 0]);
full = new FullPath(cases[i, 1]);
rel = new RelativePath(root, full);
Assert.AreEqual(full.ToString(), cases[i, 2]);
Assert.AreEqual(rel.ToString(), cases[i, 3]);
str1 = full;
if (str1[str1.Length - 1] == '\\') str1 = str1.Substring(0, str1.Length - 1);
str2 = rel.ToFullPath(root);
if (str2[str2.Length - 1] == '\\') str2 = str2.Substring(0, str2.Length - 1);
Assert.AreEqual(str1, str2);
Assert.AreEqual(RelativePath.ParseCanonical(cases[i, 3]).ToString(), cases[i, 3]);
}
}