Loading

判断本机ip是电信还是网通

            string location = "0";//0是网通 1是电信
            Uri uri = new Uri("http://www.ip138.com/ips138.asp");
            System.Net.HttpWebRequest req = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(uri);
            req.Method = "get";
            using (System.IO.Stream s = req.GetResponse().GetResponseStream())
            {
                using (System.IO.StreamReader reader = new System.IO.StreamReader(s,Encoding.GetEncoding("gb2312")))
                {
                    string str = reader.ReadToEnd();
                    if (str.Contains("电信"))
                    {
                        location = "1";
                    }
                }
            }

posted @ 2016-02-19 13:27  repeatedly  阅读(406)  评论(1编辑  收藏  举报