C# Winform 域名得到(查询)(服务器所在) IP  cs

public string GetIPByDomain(string url)
{
    if (url.Trim() == string.Empty)
        return "";
   try
    {
        System.Net.IPHostEntry host = System.Net.Dns.GetHostEntry(url);
        return host.AddressList.GetValue(0).ToString();
   }
    catch (Exception e)
    {
       throw e;
    }
}
 

							
		
posted @ 2009-02-25 20:48  binlunia  阅读(215)  评论(0编辑  收藏  举报