I am having problems converting a network path to a UNC Path (From G:\
to \\Server\MyGDrive for instance)
I have tried different ways of doing it, with codes from the net that
supposedly should work.
Here is code 1:
*******************************************************
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<%@ Page Language="VB" Trace=true Debug="true" %>
<html>
<body>
<%
Dim ret As Integer
Dim out As String = New String(" ", 260)
Dim len As Integer = 260
ret = WNetGetConnection("G:", out, len)
response.write("path: " & out)
%>
<script runat="Server" Language="VB">
Public Declare Function WNetGetConnection Lib "mpr.dll" Alias _
"WNetGetConnectionA" (ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, ByRef cbRemoteName As
Integer) As Integer
</script>
*******************************************************
And Code 2:
*******************************************************
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="System.Text" %>
<%@ Import Namespace="System.Runtime.InteropServices" %>
<%@ Page Language="VB" Trace=true Debug="true" %>
<html>
<body>
<%
Dim sb As New StringBuilder(300)
Dim size As Int32 = sb.Capacity
WNetGetConnection("G:", sb, size)
response.Write("Path: " & sb.ToString)
%>
<script runat="Server" Language="VB">
<DllImport("mpr.dll", SetLastError:=False, CharSet:=CharSet.Auto)> _
public shared Function WNetGetConnection( _
ByVal localName As String, _
ByVal remoteName As StringBuilder, _
ByRef remoteSize As Int32) As Int32
End Function
</script>
*******************************************************
None of these 2 codes return anything at all, just an empty string.
Am I missing something simple here?
Thanks