Пример #1
0
        private static List <string> GetLocalNetworkIPs()
        {
            List <string> result = new List <string>();

            LocalExecutor executor = new LocalExecutor();

            executor.ExecuteCommandWithStreamOutput("arp.exe", "-a",
                                                    (reader) =>
            {
                string line = string.Empty;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("  "))
                    {
                        var items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (items.Length == 3)
                        {
                            result.Add(items[0]);
                        }
                    }
                }

                return(string.Empty);
            });

            return(result);
        }
Пример #2
0
        private static string GetMachineName(string ipAddress)
        {
            LocalExecutor executor = new LocalExecutor();

            return(executor.ExecuteCommandWithStreamOutput("nslookup", ipAddress,
                                                           (reader) =>
            {
                string line = string.Empty;
                while ((line = reader.ReadLine()) != null)
                {
                    if (line.StartsWith("Name:"))
                    {
                        var items = line.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
                        if (items.Length == 2)
                        {
                            return items[1];
                        }
                    }
                }

                return string.Empty;
            }));
        }