C#获取本机公网IP
2024-10-12 08:17:30
/// <summary>
/// 获取本机公网IP
/// </summary>
/// <returns></returns>
public static string GetIP_Lan()
{
string tempip = "127.0.0.1";
try
{
WebRequest wr = WebRequest.Create("http://www.ip138.com/ip2city.asp");
Stream s = wr.GetResponse().GetResponseStream();
StreamReader sr = new StreamReader(s, Encoding.Default);
string all = sr.ReadToEnd();
int start = all.IndexOf("[") + ;
int end = all.IndexOf("]", start);
tempip = all.Substring(start, end - start);
sr.Close();
s.Close();
}
catch
{
}
return tempip;
}
最新文章
- acm结束了
- XPlane android 2D手游开发实战
- 支付宝集成后报错ALI38173
- delphi7 编译程序时报win32.indcu.a病毒的解决方法
- c#:Reflector+Reflexil 修改编译后的dll/exe文件
- IM客户端Socks 5代理协议应用
- VideoView
- Java基础知识强化之集合框架笔记75:哈希表
- .Net互操作2
- Pair of Numbers
- Qt 错误汇集贴
- 在网页中获取 facebook page 的内容
- vue指令v-if示例解析
- HashMap实现分析
- linux常用命令合集(未完)
- 理解 docker 容器中的 uid 和 gid
- Automated EBS Snapshots using AWS Lambda &; CloudWatch
- dbms_redefinition在线重定义表结构 可以在表分区的时候使用
- php中json_decode及foreach使用总结
- Struts2 框架使用 核心以及其他详细配置