最佳/最简单/最快速的方式来获取两个文件之间的相对路径? [英] Best/Easiest/Quickest way to get relative path between two files?

查看:474
本文介绍了最佳/最简单/最快速的方式来获取两个文件之间的相对路径?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在重构一些C#代码,其中一部分是重做一些引用,因为我们完全重做文件夹结构。我想做的只是进入.csproj或.sln文件并修改路径。

I'm in the midst of some refactoring some C# code and part of this is to redo some references, because we're redoing the folder structure entirely. What I'd like to do is just go into the .csproj or .sln file and modify the paths.

然而,一些引用有一些路径,如

However some of the references have paths like

"../../../../../../ThirdParty/SomeMicrosoftLibrary/bin/Debug/SomeMicrosoftLibrary.dll

由于我们已经移动了一切,我需要找到新的相对路径,但我绝对讨厌尝试这样做(弄清楚我需要多少个斜杠和时期),因为它总是感觉像是一些命中或错过科学。

And since we've moved everything around I need to find the new relative path. But I absolutely hate trying to do this (figure out how many slashes and periods I need to put in) since it always feels like some hit or miss science.

有没有一些简单的方法说明这里的文件A,这里是文件B,与文件A相关的文件B的相对路径是什么?

Is there some easy way (utility, script, snippet of code) to say "here's file A, here's file B, what is the relative path of file B in relation to file A?"

推荐答案

生成相对路径

它是在Java中,但很容易翻译成C#。

It's in Java, but easily translatable to C#.

这篇关于最佳/最简单/最快速的方式来获取两个文件之间的相对路径?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆