public string MakeRelativePath(string fromPath, string toPath)
{
int iLastDir = -1;
int i;
for (i = 0; i < fromPath.Length && i < toPath.Length; ++i)
{
if (fromPath[i] != toPath[i])
break;
if (fromPath[i] == this.sepChar)
iLastDir = i + 1;
}
var sb = new StringBuilder();
if (iLastDir <= 1)
return toPath;
for (i = iLastDir; i < fromPath.Length; ++i)
{
if (fromPath[i] == this.sepChar)
{
sb.Append("..");
sb.Append(sepChar);
}
}
sb.Append(toPath.Substring(iLastDir));
return sb.ToString();
}