|
|
Title | List the places in the network neighborhood in Visual Basic 2005 |
Description | This example shows how to list the places in the network neighborhood in Visual Basic 2005. |
Keywords | network, network neighborhood, Visual Basic 2005 |
Categories | Files and Directories, Internet |
|
|
Note: Add a reference to the COM object "Windows Script Host Object Model."
The program creates a WScript.Shell object and uses its SpecialFolders property to find the NetHood special folder. It creates a DirectoryInfo object for that folder and loops through the subdirectories it contains displaying their names.
|
|
Imports System.IO
Imports IWshRuntimeLibrary
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles MyBase.Load
' Make a Windows Script Host Shell object.
Dim wsh_shell As IWshShell3 = _
CreateObject("WScript.Shell")
' Find the Nethood folder.
Dim special_folders As WshCollection = _
wsh_shell.SpecialFolders
Dim nethood_path As String = _
special_folders.Item("Nethood")
Dim di As New DirectoryInfo(nethood_path)
' Enumerate the subdirectories in Nethood.
For Each subdir As System.IO.DirectoryInfo In _
di.GetDirectories()
lstLinks.Items.Add(subdir.Name)
Next subdir
End Sub
End Class
|
|
|
|
|
|