Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/windows/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/84.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 给定一条路径,如何找到它的宿主?_C#_Windows_Network Programming - Fatal编程技术网

C# 给定一条路径,如何找到它的宿主?

C# 给定一条路径,如何找到它的宿主?,c#,windows,network-programming,C#,Windows,Network Programming,如何实现此功能: GetHost("C:\MyFolder"); //Local GetHost("D:\MyFolder"); //Local GetHost("\\FileServer1\MyFolder"); //FileServer1 GetHost("Y:\MyFolder"); //FileServer1 GetHost("\\LocalSharedFolder\MyOtherFolder"); //Local GetHost("\\SpecialSharedFolder\YetAn

如何实现此功能:

GetHost("C:\MyFolder"); //Local
GetHost("D:\MyFolder"); //Local
GetHost("\\FileServer1\MyFolder"); //FileServer1
GetHost("Y:\MyFolder"); //FileServer1
GetHost("\\LocalSharedFolder\MyOtherFolder"); //Local
GetHost("\\SpecialSharedFolder\YetAnotherFolder"); //FileServer2
Edit1:

到目前为止,我已经尝试过玩杂耍,

可以告诉我磁盘是否是本地的,如果是“Y://”。如果是
\\LocaSharedFolder
,可以为我指出它的网络路径,在这里我可以提取它的主机名…

请告诉我们您尝试了什么。我相信这会有帮助: