Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

IP Adress

Status
Not open for further replies.

Worel

Programmer
Sep 16, 2002
5
0
0
AT
Hi there!
Maybe there is someone who can help me with my problem:
Are there any functions in C#, to read the IP Adress from the Computer where the App is running?
(There MUST be a way!)

THX
 
Hi Worel.

Try this solution from Tom Archer and Andrew Whitechapel:

using System;
using System.Net;

class Workstation
{
public Workstation()
{
IPAddress ipAddress = Dns.Resolve(HostName).AddressList[0];
IPAddressString = ipAddress.ToString();
}

public const string HostName = "Your Machine name";
public readonly string IPAddressString;
}

class GetIpAddress
{
public static void Main()
{
Workstation workstation = new Workstation();
Console.WriteLine("The IP address for '{0}' is {1}", Workstation.HostName,
workstation.IPAddressString);
}
}

 
Hi,

I just became a member and wanted to register my comments above as so instead a Visitor.

Regards,
Cosmo
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top