//:
public static bool IsExist(string uri)
{
HttpWebRequest req = null;
HttpWebResponse res = null;
try
{
req = (HttpWebRequest)WebRequestCreate(uri);
reqMethod = HEAD;
reqTimeout = ;
res = (HttpWebResponse)reqGetResponse();
return (resStatusCode == HttpStatusCodeOK);
}
catch
{
return false;
}
finally
{
if (res != null)
{
resClose();
res = null;
}
if (req != null)
{
reqAbort();
req = null;
}
}
}
//:
private bool UrlExistsUsingXmlHttp(string url)
{
//注意此方法需要引用Msxmldll
MSXMLXMLHTTP _xml();
_xmlhttpopen(HEAD url false null null);
_xmlhttpsend();
return (_xmlhttpstatus == );
}
//:
private bool UrlExistsUsingSockets(string url)
{
if (urlStartsWith(//)) url = urlRemove( //Length);
try
{
SystemNetIPHostEntry ipHost =SystemNetDnsGetHostEntry(url);// SystemNetDnsResolve(url);
return true;
}
catch (SystemNetSocketsSocketException se)
{
SystemDiagnosticsTraceWrite(seMessage);
return false;
}
}