Click here to Skip to main content
15,669,438 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:

How can I compare between the operating system if it's win XP or less, then do some code, else if its win 7 do another code?

I know there is platform like this:: system name or platform .getinfo

But how to do the first condition?

I hope you can help :-O
Updated 12-Jan-11 6:11am
Dalek Dave 12-Jan-11 11:42am    
Edited for Grammar and Readability.

Use the Version Class[^] to check which OS you are on.

Sorry, CodeProject stopped responding before I was able to amend my answer to the OperatingSystem[^] class.
Share this answer
Sergey Alexandrovich Kryukov 12-Jan-11 11:58am    
Richard, you may be mixed up some things. This class per se does not help you to get OS information; you need Environment -- see my answer.
Sergey Alexandrovich Kryukov 12-Jan-11 14:33pm    
Sure, then my 5.
Use System.Environment class, the property Environment.OSVersion:[^][^]

Basically, you do this:

System.OperatingSystem os = System.Environment.OSVersion;

and learn what you need from os.
Share this answer
Richard MacCutchan 12-Jan-11 13:43pm    
Yes, the system went down before I was able to correct my answer; see my update.
Аslam Iqbal 12-Jan-11 14:30pm    
Additionally add this: VerCheck = System.Environment.OSVersion.Version.Major... Have my 5.
Dalek Dave 12-Jan-11 15:24pm    
Good Answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900