Example #1
0
        static IPHelper()
        {
            const string fileName   = "App_Data/ipdb.dat";
            string       configFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, fileName);

            IPHelper.EnableFileWatch = true;
            IPHelper.Load(configFile);
        }
Example #2
0
        /// <summary>
        /// 获取IP地址所在地
        /// </summary>
        /// <param name="ip">ip地址</param>
        /// <param name="separator">分割符,默认-</param>
        /// <returns>如:"中国-湖北-武汉"</returns>
        public static string GetFullName(string ip, string separator = "-")
        {
            string fullname = "";

            string[] ipstrarr = IPHelper.Find(ip);
            ipstrarr = ipstrarr.Where(a => !string.IsNullOrWhiteSpace(a)).Distinct().ToArray();
            fullname = string.Join(separator, ipstrarr);
            return(fullname);
        }