// description of your code here


public string FindOS()
{
OperatingSystem os = Environment.OSVersion;
string osName = string.Empty;
if (os.Platform == PlatformID.Win32NT)
{
switch (os.Version.Major)
{
case 5:
if (os.Version.Minor != 0)
osName = "Windows XP";
break;

case 6:
if (os.Version.Minor == 0)
osName = "Windows Vista";
else
osName = "Windows 7";
break;

default: break;

}
}

return osName;
}

Read more: http://feeds.dzone.com/~r/dzone/snippets/~3/184vcGxuuYw/12723