I've tried everything I can think of, does anyone know a way to find the servername on a workstation using c#.

No matter what I try I cannot find the name.

HAVE YOU CHECKED THIS CODE

using System.Net;
string sHostname  =  Dns.GetHostName;
string IPAddress = GetIPAddress(sHostname);

// function to find the IPAddress
public string GetIPAddress(string sHostName)
	{
			IPHostEntry ipEntry = Dns.GetHostByName(sHostName);
			IPAddress [] addr = ipEntry.AddressList;
			string sIPAddress = addr[0].ToString();
			return sIPAddress;
		}

Can you share what you have done so far?

I'm getting error messages on

string sHostname = Dns.GetHostName;

Error 1 Cannot convert method group 'GetHostName' to non-delegate type 'string'. Did you intend to invoke the method? H:\SAVED\frmMain.cs 1056 36 OTCAutomation

and error on

IPHostEntry ipEntry = Dns.GetHostByName(sHostName);

Warning 2 'System.Net.Dns.GetHostByName(string)' is obsolete: '"GetHostByName is obsoleted for this type, please use GetHostEntry instead. http://go.microsoft.com/fwlink/?linkid=14202"' H:\SAVED\frmMain.cs 1059 35 OTCAutomation

The closest I got was using Notessession class, then servername property... but helpfile says when server is on a workstation it returns blank.

thanks for your help!

so after putting a little work into what you gave me, it does return the Windows server name... but not the lotus notes server name. Any idea how to specify for lotus notes?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.