In C# how do I get the list of local computer names like what one gets viewing the Network in windows explorer

12,865

Solution 1

You can try using the System.DirectoryServices namespace.

var root = new DirectoryEntry("WinNT:");
foreach (var dom in root.Children) {
    foreach (var entry in dom.Children) {
        if (entry.Name != "Schema") {
            Console.WriteLine(entry.Name);
        }
    }
}

Solution 2

You need to broadcast an ARP request for all IPs within a given range. Start by defining the base IP on your network and then setting an upper identifier.

I was going to write up some code examples etc but it looks like someone has covered this comprehensively here;

Stackoverflow ARP question

Solution 3

This seems to be what you are after: How get list of local network computers?

In C#: you can use Gong Solutions Shell Library (https://sourceforge.net/projects/gong-shell/)

Share:
12,865

Related videos on Youtube

Admin
Author by

Admin

Updated on June 04, 2022

Comments

  • Admin
    Admin almost 2 years

    There are a lot of questions about getting the name and IP addresses of the local machine and several about getting IP addresses of other machines on the LAN (not all answered correctly). This is different.

    In windows explorer if I select Network on the side bar I get a view of local machines on my LAN listed by machine name (in a windows workgroup, anyway). How do I get that same information programatically in C#?

  • Willie Cheng
    Willie Cheng almost 8 years
    please follow thus [URL]( stackoverflow.com/help) it will be useful to raise your content quality up

Related