Private Declare Ansi Function WNetGetConnection Lib "mpr.dll" Alias "WNetGetConnectionA" (ByVal lpszLocalName As String, ByVal lpszRemoteName As System.Text.StringBuilder, ByRef cbRemoteName As Int32) As Int32
Public Shared Function PathtoUNC(ByVal strpath As String) As String
On Error GoTo errortrap
Dim sbUNCName As New System.Text.StringBuilder(300)
Dim UNCPath As String
Dim iCapacity As Long = sbUNCName.Capacity
If strpath.Substring(0, 1).ToUpper > "E" And strpath.Substring(0, 1).ToUpper <= "Z" Then
WNetGetConnection(strpath.Substring(0, 2), sbUNCName, iCapacity)
UNCPath = Path.Combine(sbUNCName.ToString.TrimStart, strpath.Substring(3)).ToString()
Return UNCPath
Else
Return strpath
End If
Exit Function
errortrap:
Resume Next
End Function