public IPAddress GetIP()
{
WebClient client = new WebClient();
byte[] bytRecv = client.DownloadData("http://www.ip138.com/"); //下載數據
string str = System.Text.Encoding.GetEncoding("gb2312").GetString(bytRecv);
string r = @"(((\d{1,3})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))";
string ip = System.Text.RegularExpressions.Regex.Match(str, r).ToString(); //提取信息
return IPAddress.Parse(ip);
}
{
WebClient client = new WebClient();
byte[] bytRecv = client.DownloadData("http://www.ip138.com/"); //下載數據
string str = System.Text.Encoding.GetEncoding("gb2312").GetString(bytRecv);
string r = @"(((\d{1,3})|(1\d{2})|(2[0-4]\d)|(25[0-5]))\.){3}((\d{1,2})|(1\d{2})|(2[0-4]\d)|(25[0-5]))";
string ip = System.Text.RegularExpressions.Regex.Match(str, r).ToString(); //提取信息
return IPAddress.Parse(ip);
}
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货