Mike
Thu Jun 22 14:13:01 CDT 2006
Try this code:
using System.Net;
internal static void TestConnection()
{
// Get IP-Address-Information
string HostName = Dns.GetHostName();
IPHostEntry HostIP = Dns.GetHostEntry(HostName);
string HostIPAddress = HostIP.AddressList[0].ToString();
//If the device is set to loopback, no network connection exists
if (HostIPAddress == IPAddress.Parse("127.0.0.1").ToString())
{
MessageBox.Show("There is no network connection.");
return;
}
// Now we use a simple Web Request/Response to test for
connectivity
// to the WebService
Cursor.Current = Cursors.WaitCursor;
try
{
WebResponse resp = null;
WebRequest req =
WebRequest.Create("
http://www.wochners-institut.de");
req.Timeout = 10000;
resp = req.GetResponse();
MessageBox.Show("Internet is there...!");
}
catch (Exception ex)
{
MessageBox.Show("There is network connection, but the
website is not reachable...\n" + ex.Message);
}
finally
{
Cursor.Current = Cursors.Default;
}
}
"arunmib" wrote:
> Hi,
> I have a doubt. I need to know whether internet connection is
> present in the device or not.
> I tried 'InternetGetConnectedState' but I find it only says
> whether my system is configured
> for it or not.
>
> Some help. regards,
>
> Arun.
>
>