Ver Mensaje Individual
  #60  
Antiguo 31-07-2014
Avatar de nlsgarcia
[nlsgarcia] nlsgarcia is offline
Miembro Premium
 
Registrado: feb 2007
Ubicación: Caracas, Venezuela
Posts: 2.206
Reputación: 21
nlsgarcia Tiene un aura espectacularnlsgarcia Tiene un aura espectacular
Club Delphi,

Cita:
Empezado por neftali2
...Testeando, testeando...


Código:
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Text;
  using System.Net;
  using System.IO;
  using System.Net.NetworkInformation;
    
  namespace TestClubDelphi
  {
      class Program
      {
          static bool CodeHtml(string Url)
          {
              HttpWebRequest Request = (HttpWebRequest)WebRequest.Create(Url);
              Request.Method = "GET";
              WebResponse reply = Request.GetResponse();
              
              string html;
    
              try
              {
                  using (StreamReader sr = new StreamReader(reply.GetResponseStream(), Encoding.UTF8))
                  {
                      html = sr.ReadToEnd();
                      using (StreamWriter sw = File.CreateText(@"C:\ClubDelphi.html"))
                      {
                          sw.WriteLine(html);
                      }
                  }
                  return true;
              }
              catch(Exception e)
              {
                  Console.WriteLine(e.Message);
                  return false;
              }
              finally
              {
                  reply.Close();
              }
          }
      
          static void Main(string[] args)
          {
              IPHostEntry address = Dns.GetHostEntry("www.clubdelphi.com");
              Ping Pings = new Ping();
              int timeout = 10000;
    
              if (Pings.Send(address.AddressList[0], timeout).Status == IPStatus.Success)
              {
                  if (CodeHtml("http://www.clubdelphi.com"))
                  {
                      Console.WriteLine("Club Delphi esta Online");
                  }
                  else
                  {
                      Console.WriteLine("Llamar a Casimiro :)");
                  }
              }
              else
              {
                  Console.WriteLine("Llamar a Casimiro :)");
              }
                          
              Console.ReadKey();
          }
      }
  }
Todo Ok

Nelson.
Responder Con Cita