Click here to Skip to main content
15,892,697 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am using the following code for list all the computers in a network. It is working fine in all all OS except Windows 10. while debugging I could see that the "childentry" returns nothing. Also there is no error on this code.

C#
DirectoryEntry ParentEntry = new DirectoryEntry();
            try
            {
                
                ParentEntry.Path = "WinNT:";
                foreach  (DirectoryEntry childEntry in ParentEntry.Children)
                {
                    TreeNode newNode = new TreeNode(childEntry.Name);
                    if (childEntry.SchemaClassName == "Domain")
                    {
                        TreeNode ParentDomain = new TreeNode(childEntry.Name);
                        treeView1.Nodes.AddRange(new TreeNode[] { ParentDomain });
                        //DirectoryEntry SubChildEntry;
                        DirectoryEntry SubParentEntry = new DirectoryEntry();
                        SubParentEntry.Path = "WinNT://" + childEntry.Name;
                        foreach  (DirectoryEntry SubChildEntry in SubParentEntry.Children)
                        {
                            TreeNode newNode1 = new TreeNode(SubChildEntry.Name);
                            if (SubChildEntry.SchemaClassName == "Computer")
                            {
                                ParentDomain.Nodes.Add(newNode1);
                            }
                        }
                    }
                }
             
            }
            catch (Exception Excep)
            {
                MessageBox.Show ("Error While Reading Directories");
            }
            finally
            {
                ParentEntry = null;
            }


What I have tried:

Searched any kind of solution for this on the net.
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900