[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 306
  • Last Modified:

C# machine name

How can I get machine name and "IP address" in C#.
0
vivekj2004
Asked:
vivekj2004
1 Solution
 
ToddBeaulieuCommented:
options:

string name = Environment.MachineName;
string name = System.Net.Dns.GetHostName();
string name = System.Windows.Forms.SystemInformation.ComputerName;
string name = System.Environment.GetEnvironmentVariable(“COMPUTERNAME”);

for IP addresses, you may have several:


IPAddress[] a = Dns.GetHostByName(Dns.GetHostName()).AddressList;
   for (int i=0; i<a.Length; i++)
      Console.WriteLine ("IpAddr[{0}]={1}",i,a[i]); }

Open in new window

0

Featured Post

Learn to develop an Android App

Want to increase your earning potential in 2018? Pad your resume with app building experience. Learn how with this hands-on course.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now