System.IO.Path.GetPathRoot解决方法UNC路径 [英] System.IO.Path.GetPathRoot workaround for UNC paths

查看:250
本文介绍了System.IO.Path.GetPathRoot解决方法UNC路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

GetPathRoot似乎不支持UNC路径。从下面的code的结果只是被修剪掉file.txt的

GetPathRoot doesn't seem to support UNC paths. The result from the code below is simply trimming off file.txt

string root = Path.GetPathRoot("\\servername.pvt\sub dir\file.txt");

什么是一个好的解决办法?

What is a good workaround?

推荐答案

返回值是正确的。根是在共享,而不是服务器!例如:

The return value is correct. The root is the share, and not the server! For example:

Path.GetPathRoot(@"\\servername.pvt\sharename\directory\file.txt");

这将返回 @\\ servername.pvt \共享名。服务器名称加上共享名构成了根路径。

This returns @"\\servername.pvt\sharename". The server name plus the share name constitutes the path root.

这篇关于System.IO.Path.GetPathRoot解决方法UNC路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆