LumiSoft.Net.Dns.Client.Dns_Client.Dns_Client C# (CSharp) Method

Dns_Client() static private method

Static constructor.
static private Dns_Client ( ) : System
return System
        static Dns_Client()
        {
            // Try to get system dns servers
            try{
                string[] retVal = new string[]{"",""};

                ProcessStartInfo pInfo = new ProcessStartInfo("ipconfig","/all");
                pInfo.RedirectStandardOutput = true;
                pInfo.UseShellExecute = false;
                pInfo.CreateNoWindow = true;

                Process p = Process.Start(pInfo);
                StreamReader r = p.StandardOutput;

                bool secondary = false;
                string line = r.ReadLine();
                while(line != null){
                    if(line.Trim().ToLower().StartsWith("dns servers")){
                        // Primary dns server
                        retVal[0] = line.Substring(line.IndexOf(':') + 1).Trim();

                        line = r.ReadLine();
                        if(line == null){
                            break;
                        }
                        line = r.ReadLine();
                        if(line == null){
                            break;
                        }

                        // There is secondary dns server
                        if(line.Trim().IndexOf(":") == -1){
                            secondary = true;
                            retVal[1] = line.Trim();
                        }
                        break;
                    }
                    line = r.ReadLine();
                }

                if(secondary){
                    m_DnsServers = retVal;
                }
                else{
                    m_DnsServers = new string[]{retVal[0]};
                }
            }
            catch{
            }
        }