fruitloopy
asked on
VB.NET - Listing mapped drives on a remote PC
I had written some code in VB.NET/Visual Studio 2012 but since then I lost all data on the hard drive and consequently lost the source code.
I have used .NET Reflector to get back most of it but I am puzzled by some entries which don't make any sense to me as I can't remember the code I used and it has changed it slightly:
enumerator = objects.GetEnumerator
Do While enumerator.MoveNext
Dim current As ManagementObject = DirectCast(enumerator.Curr ent, ManagementObject)
I have no idea what was there originally. Any help?
I have used .NET Reflector to get back most of it but I am puzzled by some entries which don't make any sense to me as I can't remember the code I used and it has changed it slightly:
Private Sub btnRefresh_Click(sender As Object, e As EventArgs) Handles btnRefresh.Click
Me.ListView1.Items.Clear()
Me.Cursor = Cursors.WaitCursor
Application.DoEvents()
Main.WMICall(Main.txtHostName.Text)
If Main.WMICall(Main.txtHostName.Text) Then
Dim scope As New ManagementScope(("\\" & Main.txtHostName.Text & "\root\cimv2"))
scope.Connect()
Try
Dim enumerator As ManagementObject
Dim query As New ObjectQuery("Select * from Win32_MappedLogicalDisk")
Dim objects As ManagementObjectCollection = New ManagementObjectSearcher(scope, query).Get
Try
enumerator = objects.GetEnumerator
Do While enumerator.MoveNext
Dim current As ManagementObject = DirectCast(enumerator.Current, ManagementObject)
Dim items As String() = New String(3 - 1) {}
items(0) = ToString(current.Item("Name"))
items(1) = ToString(current.Item("ProviderName"))
Dim item As New ListViewItem(items)
Me.ListView1.Items.Add(item)
Loop
Finally
If (Not enumerator Is Nothing) Then
enumerator.Dispose()
End If
End Try
Catch ex As Exception
End Try
End If
Me.Cursor = Cursors.Default
End Sub
It's this part that isn't recognised:enumerator = objects.GetEnumerator
Do While enumerator.MoveNext
Dim current As ManagementObject = DirectCast(enumerator.Curr
I have no idea what was there originally. Any help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
It's this code that got the job done:
Open in new window
Thanks