1 /// <summary>
2 /// 验证IP格式是否输入正确
3 /// </summary>
4 /// <param name="ip"></param>
5 /// <returns></returns>
6 private bool IsIpAddress(string ip)
7 {
8 bool blnTest = false;
9 bool _Result = true;
10 Regex regex = new Regex("^[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}.[0-9]{1,3}$");
11 blnTest = regex.IsMatch(ip);
12 if (blnTest == true)
13 {
14 string[] strTemp = ip.Split(new char[] { '.' });
15 ip.Split(new char[] { '.' });
16 for (int i = 0; i < strTemp.Length; i++)
17 {
18 if (Convert.ToInt32(strTemp[i]) > 255)
19 {
20 _Result = false;
21 }
22 }
23 }
24 else
25 {
26 _Result = false;
27 }
28 return _Result;
29 }