http://expert.csdn.net/Expert/topic/2930/2930652.xml?temp=.3042871
http://expert.csdn.net/Expert/topic/2934/2934264.xml?temp=.2464868
http://expert.csdn.net/Expert/topic/2934/2934264.xml?temp=.2464868
解决方案 »
- C# 有没有人知道从2的0次方到2的9次方的和有多少种组合?又或者……
- c#界面随电脑分辨率自动适应
- 请问刷新带参数水晶报表如何不弹出“输入参数值”对话框?
- C#中怎样改变鼠标的形状?
- 如何用c#,远程访问sqlserver2005express
- 如何让textbox的keydown事件捕捉tab键
- 请问如何让一个应用程序运行在我窗口的一块区域内。
- 各位认为在开发C/S和B/S架构的应用系统时,.net平台(主要是C#)能成为和JAVA平起平坐的开发工具,大概会在几年后呢?
- vs2005(c#)+sql server2005开发WINFORM数据库管理系统的报表打印问题
- 怎么样访问控件里面的控件的属性?
- 远程不断变化中的文件数据怎么样读取?
- 请问以下异常是什么原因产生的??
try
{
IPAddress hostIPAddress = IPAddress.Parse(IpAddressString);
IPHostEntry hostInfo = Dns.GetHostByAddress(hostIPAddress);
// Get the IP address list that resolves to the host names contained in
// the Alias property.
IPAddress[] address = hostInfo.AddressList;
// Get the alias names of the addresses in the IP address list.
String[] alias = hostInfo.Aliases; Console.WriteLine("Host name : " + hostInfo.HostName);
Console.WriteLine("\nAliases :");
for(int index=0; index < alias.Length; index++) {
Console.WriteLine(alias[index]);
}
Console.WriteLine("\nIP address list : ");
for(int index=0; index < address.Length; index++) {
Console.WriteLine(address[index]);
}
}
catch(SocketException e)
{
Console.WriteLine("SocketException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(FormatException e)
{
Console.WriteLine("FormatException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(ArgumentNullException e)
{
Console.WriteLine("ArgumentNullException caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
catch(Exception e)
{
Console.WriteLine("Exception caught!!!");
Console.WriteLine("Source : " + e.Source);
Console.WriteLine("Message : " + e.Message);
}
作者:孟宪会 出自:【孟宪会之精彩世界】 发布日期:2003年6月15日 8点56分15秒
--------------------------------------------------------------------------------
[C#]
string s ="";
System.Net.IPAddress[] addressList = Dns.GetHostByName(Dns.GetHostName()).AddressList;
for (int i = 0; i < addressList.Length; i ++)
{
s += addressList[i].ToString() + "\n";
}
textBox1.Text = s;
[VB.NET]
Dim s As String = ""
Dim addressList As System.Net.IPAddress() = Dns.GetHostByName(Dns.GetHostName()).AddressList
Dim i As Integer
For i = 0 To addressList.Length - 1
s += addressList(i).ToString() + ControlChars.Lf
Next i
textBox1.Text = s
IPAddress 是在那个命名空间中?
因为,我调试时提示“不能识别的类型”
Dns 是在那个命名空间中?
using System.Net.Sockets;
的办法运行成功。而且代码比较
精炼。
最后请问 athossmth(athos)
==============================================
addressList(i).ToString() 就是本机的本地IP地址;
ControlChars.Lf 就是本机上网的IP地址;
==============================================
对吗?