I’m looking to grab the SharePoint Configuration Database version via C# and found the SPConfigDatabase class under Microsoft.SharePoint.Administration which has a Version member. This is exactly what I’m looking for, but this is now obsolete.
What is the best method for doing this? Ideally I’d like to grab the Cumulative Update date as well, though this is essentially just another name for the version number.
Thanks
The way to get it using C# is to use the Microsoft.SharePoint.Administration.SPFarm class and the property you are looking for is BuildVersion:
As that returns a System.Version object, you may want to concatenate the values together to make the string appear as it does in the central admin:
Also, please note that to access the SPFarm.Local property, you will need to be running the code in 64-bit mode as well as have an authorized account. In fact, with the UAC enabled on my VM I needed to run my code by right-clicking on it and choosing “Run as Administrator” as well.