csharp 绝对相对路径 - 来自http://stackoverflow.com/questions/13266756/absolute-to-relative-path和http://stack

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了csharp 绝对相对路径 - 来自http://stackoverflow.com/questions/13266756/absolute-to-relative-path和http://stack相关的知识,希望对你有一定的参考价值。

public string GetRelativePath(string filePath, string referencePath)
{
  var fileUri = new Uri(filePath);
  var referenceUri = new Uri(referencePath);
  var relativeUri = referenceUri.MakeRelativeUri(fileUri).ToString();
  var relativePath = relativeUri.Replace('/', Path.DirectorySeparatorChar);
  return relativePath;
}

以上是关于csharp 绝对相对路径 - 来自http://stackoverflow.com/questions/13266756/absolute-to-relative-path和http://stack的主要内容,如果未能解决你的问题,请参考以下文章