PDA

View Full Version : سوال: به دست آوردن لیست پوشه های یک درایو



sysman_20
سه شنبه 05 خرداد 1388, 15:22 عصر
چگونه می توانم بفهمم که کاربر در حال حاضر به اینترنت متصل هست یاخیر؟

pesar irooni
سه شنبه 05 خرداد 1388, 23:59 عصر
از کلاس HttpWebRequest تو فضای نام System.Net استفاده کن .
این کدی که من قبلا برای کاری نوشته بودم.


HttpWebRequest req = (HttpWebRequest)WebRequest.Create("http://YourWebSite");

HttpWebResponse webresponse = null;

Retry:
try
{
i++;
webresponse = (HttpWebResponse)req.GetResponse();
}
catch (WebException we)
{
if (we.Status == WebExceptionStatus.ProtocolError &&
((HttpWebResponse)we.Response).StatusCode == HttpStatusCode.NotFound)
{
//remote url not found, 404 and must remove from url
UrlServer.RemoveUrl(_url);
}
else
{
// 3 times attempt to get response
if (we.Message.Contains("The remote name could not be resolved") && i<=3)
goto Retry;
//throw we;
UrlServer.RemoveUrl(_url);
}
}