如何使用VB.net将Unix文件路径转换为Windows路径
我正在使用acrobat返回unix路径,而不是windows路径。所以我想知道在vb.net中是否有方法将路径转换为windows路径 我尝试使用:如何使用VB.net将Unix文件路径转换为Windows路径,vb.net,path,Vb.net,Path,我正在使用acrobat返回unix路径,而不是windows路径。所以我想知道在vb.net中是否有方法将路径转换为windows路径 我尝试使用: docs(i) = javaScriptObj.path().ToString.Replace("/", "\").Substring(1) position = docs(i).IndexOf("\") docs(i) = docs(i).Substring(0, position) + ":\" + docs(i).Substring(pos
docs(i) = javaScriptObj.path().ToString.Replace("/", "\").Substring(1)
position = docs(i).IndexOf("\")
docs(i) = docs(i).Substring(0, position) + ":\" + docs(i).Substring(position + 1)
这只适用于本地文件,但在im开始使用网络驱动器时失败。谢谢尝试一下:
Private Function UnixPathToWindowsPath(UnixPath As String) As String
If String.IsNullOrWhiteSpace(UnixPath) Then Return String.Empty
Dim chunks = UnixPath.Split(New Char() {"/"c}, StringSplitOptions.RemoveEmptyEntries)
If chunks.Any Then
If chunks(0).Length = 1 Then 'Single character root, assume drive letter.
Return String.Join("\", chunks).Insert(1, ":")
Else
Return "\\" & String.Join("\", chunks)
End If
Else
Return IO.Path.DirectorySeparatorChar
End If
End Function
这假定为完整路径名,而不是部分路径