dhalfageme
dhalfageme

Reputation: 1545

Get MAC OS X Version number

I want to get the current MAC OS X Version using C#. There is a way to do it using a C# function?

I know the command sw_vers can do it, buy I prefer to avoid run a command if it is not necessary. What I need is a string like "10.4" or "10.6" or whatever.

This code:

Environment.OSVersion.ToString();

returns:

Unix 12.5.0.0 

But not 10.X that are the version numbers of mac releases

Upvotes: 1

Views: 1638

Answers (1)

BendEg
BendEg

Reputation: 21098

You should use Environment.OSVersion and to get the version Environment.OSVersion.Version

The returned version is the Darwin Kernel-Version (base of OS X). You have to map this to the OS X version, see the table under: Release history

Upvotes: 4

Related Questions