How to pull the server name from a UNC

前端 未结 5 841
借酒劲吻你
借酒劲吻你 2021-02-05 16:34

Would anyone be able to tell me how to pull the server name out of a UNC?

ex.

//servername/directory/directory

Edit : I apologize but it looks like I nee

5条回答
  •  别跟我提以往
    2021-02-05 17:03

    Ugly but it just works:

    var host = uncPath.Split(new [] {'\\'}, StringSplitOptions.RemoveEmptyEntries).FirstOrDefault();
    

提交回复
热议问题