C# C语言中的遍历路径#

C# C语言中的遍历路径#,c#,.net,path,C#,.net,Path,为什么 Console.WriteLine(Path.GetFullPath(@“\\folder1\folder2\..\anotherFolder”) 打印\\folder1\folder2\anotherFolder而不是\\folder1\anotherFolder 而Console.WriteLine(Path.GetFullPath(@“\\folder1\folder2\folder3\..\anotherFolder”)按我的预期打印\\folder1\folder2\anoth

为什么
Console.WriteLine(Path.GetFullPath(@“\\folder1\folder2\..\anotherFolder”)
打印
\\folder1\folder2\anotherFolder
而不是
\\folder1\anotherFolder

Console.WriteLine(Path.GetFullPath(@“\\folder1\folder2\folder3\..\anotherFolder”)按我的预期打印
\\folder1\folder2\anotherFolder

似乎我无法逃脱我路径的前两个文件夹。但每个文件夹后面都有两个


编辑: 实际上是:
Console.WriteLine(Path.GetFullPath(@“\server\share\…\anotherFolder”)


这解释了行为。

当您指定网络路径时,第一部分(示例中的
folder1
是服务器名称。第二部分是共享名。您可以使用
遍历实际文件夹,但不遍历共享。

使用
@
您不需要“\\\”。如果要使用UNC路径,请不要调用服务器folder1。如果要使用UNC路径,请不要调用服务器folder1。我猜这是我失去理解的一部分