吾爱破解 - LCG - LSG |安卓破解|病毒分析|www.52pojie.cn

 找回密码
 注册[Register]

QQ登录

只需一步,快速开始

查看: 5489|回复: 8
收起左侧

[其他转载] C#简单的取外网IP源码例子

[复制链接]
neicun 发表于 2013-11-17 09:42
[C#] 纯文本查看 复制代码
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Net;
using System.Windows.Forms;

namespace 取本机IP
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string url = "http://iframe.ip138.com/ic.asp";
            WebClient Http = new WebClient();
            Http.Proxy = null;//不设置代理的话,建议把这句都加上
            string result = Http.DownloadString(new Uri(url));

            string mid = GetMid(result, "您的IP是:[", "</center>");

            MessageBox.Show("您的IP是:[" + mid);
        }

        private string GetMid(string all, string r, string l)
        {
            int rn = all.IndexOf(r) + r.Length;
            int ln = all.IndexOf(l, rn);
            return all.Substring(rn, ln - rn);
        }
    }
}

发帖前要善用论坛搜索功能,那里可能会有你要找的答案或者已经有人发布过相同内容了,请勿重复发帖。

Mr丶X 发表于 2013-11-17 09:44
沙发强烈支持
Lesa 发表于 2013-11-17 09:44
bigshan 发表于 2013-11-17 09:49
liuxinming67 发表于 2013-11-17 10:02
专业的人员有用,我现在还不是专业
jyq8023yzk 发表于 2013-11-17 10:31
还行 看得懂 不会写 - -
ceorfpmba 发表于 2013-11-17 10:32
学习看看
caijunqill 发表于 2013-11-17 10:43
太好了,收藏先,水平有限,要慢慢消化,感谢楼主,论坛有你更精彩
lcylcyll 发表于 2014-4-10 00:14
这一个好像不是用正则表达式做出来的吧
您需要登录后才可以回帖 登录 | 注册[Register]

本版积分规则

快速回复 收藏帖子 返回列表 搜索

RSS订阅|小黑屋|处罚记录|联系我们|吾爱破解 - LCG - LSG ( 京ICP备16042023号 | 京公网安备 11010502030087号 )

GMT+8, 2024-9-22 07:02

Powered by Discuz!

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表