C# &引用;Path.GetFullPath";和网络路径

C# &引用;Path.GetFullPath";和网络路径,c#,.net,path,C#,.net,Path,为什么“Path.GetFullPath”在解析网络路径上具有相对元素的路径时行为奇怪? 尝试此小示例并比较结果: using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(Path.GetFullPath(@"C:\Stay\Elim1\Eli

为什么“Path.GetFullPath”在解析网络路径上具有相对元素的路径时行为奇怪? 尝试此小示例并比较结果:

using System;
using System.IO;

namespace ConsoleApplication1 {
    class Program {
        static void Main(string[] args) {
            Console.WriteLine(Path.GetFullPath(@"C:\Stay\Elim1\Elim2\..\..\SomeFolder"));  // yields C:\Stay\SomeFolder
            Console.WriteLine(Path.GetFullPath(@"\\Stay\Elim1\Elim2\..\..\SomeFolder"));   // yields \\Stay\Elim1\SomeFolder ???
        }
    }
}
这可能是一个bug,也可能有某种意义,但我不明白


(我的机器上没有任何路径,甚至没有路径的一部分,因此这只是一个字符串操作)

当使用网络路径时,路径的第二部分是共享名,而不是目录

Console.WriteLine(Path.GetFullPath(@"C:\SomeDir\Dir1\Dir2\..\..\SomeFolder"));  
C:\SomeDir\SomeFolder

\服务器\ShareName\SomeFolder


你比我快了10秒!对。网络对我来说太聪明了!
Console.WriteLine(Path.GetFullPath(@"\\Server\ShareName\Dir1\Dir2\..\..\SomeFolder"));