Wednesday, December 28, 2005

Technical - Get Shared Drive Machine Name


To find shared drive name on the Clinet use the Javascript


One of the ASP.Net project team was having problems in getting the shared drive machine name i.e for eg k:\Test\doc1.doc they want to mapped it as \\srini\test\doc1.doc where srini is machine name.

If the client uploads a file from the shared drive and if one want to find the machine name of shared drive and stored it as \\srini\test basically they have customize this js code below


function displayNetworkShares() {
var WshNetwork = new ActiveXObject("WScript.Network");
var Drives = WshNetwork.EnumNetworkDrives()
var DriveInfo = new Array()
var j = 0

var content = "Drive Mapping "
for (i = 0; i < Drives.length; i++) {
content += "

" + Drives.Item(i) + "

"
}
document.write(content)
}



To find shared drive name on the IIS machine use the WIN32API

_
Private Shared Function WNetGetConnection( _
ByVal localName As String, _
ByVal remoteName As StringBuilder, _
ByRef remoteSize As Int32) As Int32
End Function


Client Code
Dim sb As New StringBuilder(300)
Dim size As Int32 = sb.Capacity
WNetGetConnection("G:", sb, size)
Label1.Text = "Local : G Remote :" & sb.ToString()

0 Comments:

Post a Comment

<< Home