tags:

views:

128

answers:

2

Is there any way, other than referencing the Microsoft.VisualBasic.dll (such as as below in .NET 3) to retrieve to Computer Name

new Microsoft.VisualBasic.Devices.ServerComputer().Name
+12  A: 

Use System.Environment.MachineName.

binarycoder
+2  A: 

You can use System.Windows.Forms.dll and the SystemInformation class. You can also use System.Environment.MachineName or System.Environment.GetEnvironmentVariable("COMPUTERNAME"). And if you're really devoted, you can make a P/Invoke into user32.dll to call the appropriate Win32 API.

JSBangs
+1 for the different options
johnc