Question

I hope someone could show me how to get to total numbers of domains from my list? I am trying to get the total so I can implement a progress bar. I was able to get them to count up but unable to just get the sum.

Below is where I am at currently. I am thinking I need to convert dc to int first?

public void findalldomains()
{
    Dictionary<string, List<string>> findD = new Dictionary<string, List<string>>();
    List<int> mydomains = new List<int>();
    Domain domain = Domain.GetCurrentDomain();
    using (domain)
    {
        StringBuilder tempText = new StringBuilder();
        foreach (DomainController dc in
            domain.FindAllDiscoverableDomainControllers())
        {
            tempText.Append(dc.Name);
            tempText.Append(Environment.NewLine);
            listBox1.Items.Add(dc);
            int t = 0;
            int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
            t += domainCnt;
            Console.WriteLine(t);

        }
    }
}
// without loop and list

public static void findalldomains()
{
    int t = 0;
    //  Console.WriteLine(dc.Name);
    int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
    t += domainCnt;
    Console.WriteLine(t);
}
Était-ce utile?

La solution

How about trying

int domainCnt = Domain.GetCurrentDomain().FindAllDiscoverableDomainControllers().Count;
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top