Add "Ping" Method

This commit is contained in:
CreepyCrafter24 2020-03-24 15:55:49 +01:00
parent fa22f084a8
commit c45b28ed10
1 changed files with 17 additions and 0 deletions

View File

@ -96,6 +96,23 @@ namespace CC_Functions.Misc
WebResponse resp = req.GetResponse();
return resp.ResponseUri;
}
public static bool Ping(this Uri self)
{
try
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(self);
request.Timeout = 3000;
request.AllowAutoRedirect = true;
using WebResponse response = request.GetResponse();
return true;
}
catch
{
return false;
}
}
public static Rectangle Round(this RectangleF self) => Rectangle.Round(self);
public static Rectangle Ceiling(this RectangleF self) => Rectangle.Ceiling(self);
}