Ejemplo n.º 1
0
        /// <summary>
        /// These are the methods that get the appropriate values via different resources
        /// </summary>
        /// <returns>
        /// Adequate values. Either a FOUND value if found (i.e. DefaultGateway)...
        /// ...or EMPTY, which will infer the required value cannot be found or, in this case, the device may not be connected to a Network
        /// </returns>
        ///

        public string getExternalIP()
        {
            try
            {
                return(new WebClient().DownloadString("https://api.ipify.org"));
            }
            catch (Exception ex)
            {
                return(ExceptionHandling.getExceptionMessage(ex));
            }
        }
Ejemplo n.º 2
0
 public string getIPv4()
 {
     try
     {
         IPHostEntry IPhostEntry = Dns.GetHostEntry(Dns.GetHostName());
         string      IPv4        = EMPTY;
         foreach (IPAddress ip in IPhostEntry.AddressList)
         {
             if (ip.AddressFamily == AddressFamily.InterNetwork)
             {
                 IPv4 = ip.ToString();
             }
         }
         return(IPv4);
     }
     catch (Exception ex)
     {
         return(ExceptionHandling.getExceptionMessage(ex));
     }
 }