Sunday, August 26, 2012

Get computer names in the Network

I wanted to get all the computer's names as I was doing a till balancing program, related to a supermarket (POS application). On a report I wanted to filter the daily balance.

Daily balance of all stations and station wise. I thought this might helpful, if I share the code snippet with you.


private List ComputersInNetwork()
{
List computerList= new List();
using (DirectoryEntry root = new DirectoryEntry("WinNT:"))
{
foreach (DirectoryEntry computers in root.Children)
{
foreach (DirectoryEntry computer in computers.Children)
{
if ((computer.Name != "Schema"))
{
computerList.Add(computer.Name);
}
}
}
}
computerList.Add("All");
computerList.Sort();
return list;
}

Happy coding.

0 comments:

My Achievements

Member of

Blog Archive

Followers

free counters