c# – “Path.GetFullPath”和网络路径
发布时间:2020-12-16 01:56:12 所属栏目:百科 来源:网络整理
导读:为什么在解析网络路径上具有相关元素的路径时,“Path.GetFullPath”会表现得很奇怪? 试试这个小例子并比较结果: using System;using System.IO;namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(Pat
为什么在解析网络路径上具有相关元素的路径时,“Path.GetFullPath”会表现得很奇怪?
试试这个小例子并比较结果: using System; using System.IO; namespace ConsoleApplication1 { class Program { static void Main(string[] args) { Console.WriteLine(Path.GetFullPath(@"C:StayElim1Elim2....SomeFolder")); // yields C:StaySomeFolder Console.WriteLine(Path.GetFullPath(@"StayElim1Elim2....SomeFolder")); // yields StayElim1SomeFolder ??? } } } 它可能是一个错误,或者可能有一些意义,但我不明白. (它们中没有任何一个甚至是它们的部分真的存在于我的机器上,所以它只是一个字符串操作) 解决方法
使用网络路径时,路径的第二部分是Share-name not directory.
Console.WriteLine(Path.GetFullPath(@"C:SomeDirDir1Dir2....SomeFolder"));
Console.WriteLine(Path.GetFullPath(@"ServerShareNameDir1Dir2....SomeFolder"));
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |