Return UNC Path

Disco_gal_1

Member
Joined
Oct 1, 2004
Messages
10
Hello-

I am trying to return the unc name of a mapped drive.

I am using the Open File Dialog to allow users to select a file. OpenFileDialog1.FileName returns F:\foldername\filename.txt

I need it to return \\servername\foldername\filename.txt

Any ideas?

Thanks in advance!
 
Solved

I finally figured it out from other posts and trial and error.... I created a module and here is the code.

Module mdlDrive

Public Declare Function WNetGetConnection Lib "mpr.dll" Alias _
"WNetGetConnectionA" (ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, ByRef cbRemoteName As Integer) As Integer

Sub Main(ByVal sDriveLetter As String, ByRef sServerName As String)

Dim ret As Integer
Dim out As String = New String(" ", 260)
Dim len As Integer = 260

ret = WNetGetConnection(sDriveLetter, out, len)

sServerName = RTrim(out)

End Sub



End Module

The calling function from my form is mdlDrive.Main(sDriveLetter, sServerName)

Cheers!
 
Back
Top