Why does "Path.GetFullPath" behave strange when resolving paths with relative elements on a network path? Try this small example and compare the results:
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 ???
}
}
}
It might be a bug or there might be some sense in it, but I don't get it.
(None of the pathes or even parts of it them really exist on my machine, so its merely a string operation)
When You use a network path the second part of the path is the Share-name not directory.
Console.WriteLine(Path.GetFullPath(@"C:\SomeDir\Dir1\Dir2\..\..\SomeFolder"));
C:\SomeDir\SomeFolder
Console.WriteLine(Path.GetFullPath(@"\\Server\ShareName\Dir1\Dir2\..\..\SomeFolder"));
\Server\ShareName\SomeFolder
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With