I am trying to get a list of local network computers. I tried to use NetServerEnum
and WNetOpenEnum
API, but both API return error code 6118
Here a property that uses a LINQ query
private List NetworkHosts
{
get
{
var result = new List();
var root = new DirectoryEntry("WinNT:");
foreach (DirectoryEntry computers in root.Children)
{
result.AddRange(from DirectoryEntry computer in computers.Children where computer.Name != "Schema" select computer.Name);
}
return result;
}
}