Get all the shared folders of a computer in my network

1.7k views Asked by At

I want to get all the computers in my network and all the shared folders in it(Should work in both domain and workgroup). I was able to get all the computers in the network using below code

Dim ipproperties As NetworkInformation.IPGlobalProperties = NetworkInformation.IPGlobalProperties.GetIPGlobalProperties()
Dim domain As String = ipproperties.DomainName

Dim domainEntry As DirectoryEntry = New DirectoryEntry("WinNT://" + domain)
domainEntry.Children.SchemaFilter.Add("computer")

For Each computer As DirectoryEntry In domainEntry.Children
    ListBox1.Items.Add(computer.Name)
Next

But now i want to get shared folders of each computer. So i used this code using DirectoryEntry. But it gave error like "The group name could not be found" for a network computer. So what is the reason I am getting error. Or is there any other method to get shared folders of computers which are in my network.(I don't want to use WMI solutions)

1

There are 1 answers

4
Richard On

You could use WMI's Win32_Share: Take a look at the example here (you'll need to

  1. replace Win32_LogicalDisk with Win32_Share
  2. pass extra parameters to the ManagementObjectSearcher, as in the example here to specify a different computer.