【发布时间】:2017-09-10 08:01:43
【问题描述】:
String machineName = System.Environment.MachineName;
String filePath = @"E:\folder1\folder2\file1";
int a = filePath.IndexOf(System.IO.Path.DirectorySeparatorChar);
filePath = filePath.Substring(filePath.IndexOf(System.IO.Path.DirectorySeparatorChar) +1);
String networdPath = System.IO.Path.Combine(string.Concat(System.IO.Path.DirectorySeparatorChar, System.IO.Path.DirectorySeparatorChar), machineName, filePath);
Console.WriteLine(networdPath);
我使用String.Concat 和Path.Combine 编写了上面的代码来获取网络路径。但这只是一种解决方法,而不是具体的解决方案,可能会失败。
有没有获取网络路径的具体解决方案?
【问题讨论】: