hi,while writing the code for checking connectivity of a device, i came accross System.Net.NetworkInformation but that didnt work as i am working on windows mobile 6.0 compact framework. then i used the 3.5 framework using
using System.Net;
using System.Web;
using System.IO;
and the code as follows from one of the blogs:
private static HttpWebRequest ConnectWeb(string urlx)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(new Uri(urlx));
request.ContentType = @"application/octet-stream";
request.Credentials = CredentialCache.DefaultCredentials;
request.Timeout = 6000;
// request.Timeout(6000);
return request;
}
catch (Exception ex)
{
MessageBox.Show("CONNECTIONPROBLEM");
return null;
}
}
private bool downloadTest()
{
Stream stream;
HttpWebResponse response;
HttpWebRequest request =ConnectWeb("http://www.google.com");
if (request != null)
{
try
{
using (response = (HttpWebResponse)request.GetResponse())
{
using (stream = response.GetResponseStream())
{
byte[] data = ReadFully(stream, (int)response.ContentLength);
writeByteArrayToFile(data, "data.zip");
}
}
return true;
response.Close();
stream.Close();
}
catch (Exception ex)
{
MessageBox.Show("CONNECTIONPROBLEM");
return false;
}
}
return true;
}
But even then the ReadFully which is used to read the buffer does not work. intellisense does not show that option to be used hence i am confused, what could be the solution to detect device connected to internet
Thank You in Advance