鉴于我在路径中有一个文件:
C:\Applications\General Utils\Assembly1\Assembly1\Bin\Debug\Assembly1.dll
我正在以下路径工作:
C:\Applications\Under Development\App1\App1\
有一些简单的方法可以找到从应用程序到程序集的虚线路径:
..\..\..\General Utils\Assembly1\Assembly1\Bin\Debug\Assembly1.dll
答案 0 :(得分:6)
System.Uri uri1 = new Uri(@"C:\Applications\General Utils\Assembly1\Assembly1\Bin\Debug\Assembly1.dll");
System.Uri uri2 = new Uri(@"C:\Applications\Under Development\App1\App1\");
Uri relativeUri = uri2.MakeRelativeUri(uri1);
Console.WriteLine(relativeUri.ToString());
应该做的伎俩