如何转换通过远程主机(如
)的默认共享定义的路径\\{host}\c$\SomeFolder\SomeDeeperFolder
转换为本地路径符号,例如:
c:\SomeFolder\SomeDeeperFolder
我可以尝试拆分原始路径并获取主机或驱动器不可知的路径,然后按如下所示与C:\
进行连接,但是我寻求的是一种内置的类/方法实现更完美的转换 :
var defaultSharedPath = "\\\\someremotehostname\\c$\\SomeFolder\\SomeDeeperFolder";
// The drive is always c:\ in my case, so I can directly split with it
var path = defaultSharedPath.Split(new string[] { "\\c$\\" }, StringSplitOptions.None).ToList().Last();
var localLikePath = "C:\\" + path;
Console.WriteLine(localLikePath);