步驟1.
using System.Net;
步驟2
public static bool CheckWebReference(string url)
{
bool exists = false;
WebRequest request = WebRequest.Create(url);
request.Proxy = null;
try
{
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
exists = true;
response.Close();
}
catch
{
exists = false;
}
request.Abort();
return exists;
}
上方的url是要檢查的網路資源網址,ex: http://xxx.xxx.xxx/xxx/xxx.png
沒有留言:
張貼留言