public static void GetPulicAddress(ref string pubip, ref string address)
{
try
{
string strUrl = "http://iframe.ip138.com/ic.asp";//获得IP的网址
Uri uri = new Uri(strUrl);
WebRequest webreq = WebRequest.Create(uri);
Stream s = webreq.GetResponse().GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.Default);
string all = sr.ReadToEnd(); //读取网站返回的数据 格式:您的IP地址是:[x.x.x.x]
int i = all.IndexOf("[") + 1;
int adr = all.IndexOf("来自") + 3;
string tempadd = string.Empty,tempip=string.Empty;
tempip = all.Substring(i, 15);
tempadd = all.Substring(adr, all.Length - adr);
pubip = tempip.Substring(0,tempip.IndexOf("]"));
address = tempadd.Substring(0, tempadd.IndexOf("<"));
}
catch (Exception ex) { ComMsg.MsgErr(ex.Message); }
}