Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.
VB.Net: Path to UNC
From Wiki
Sometimes it can be handy to find the UNC for a mapped drive.
- 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 Path As String) As String
- Dim _UNCName As New System.Text.StringBuilder(300)
- Dim _UNCPath As String
- Dim _Capacity As Integer = _UNCName.Capacity
- If Not Path Is Nothing Then
- If Path.Length > 1 Then
- If Path.Substring(0, 1).ToUpper > "E" And Path.Substring(0, 1).ToUpper <= "Z" Then
- WNetGetConnection(Path.Substring(0, 2), _UNCName, _Capacity)
- _UNCPath = System.IO.Path.Combine(_UNCName.ToString.TrimStart, Path.Substring(3)).ToString()
- Return _UNCPath
- Else
- Return Path
- End If
- End If
- End If
- Return Nothing
- End Function



LTD Social Sitings
Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.