Click here to Skip to main content
16,017,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Every one....
i want to execute disk fragment form my coding by calling windows API
and my code is

Process.Start("dfrg.msc"); //It is for Windows Xp

,but i have faced a problem that for different operating system like Windows 7 or Vista the command code is different.
Means for Windows 7 the code is

Process.Start("dfrgui");

so,how can i know which operating system is running in computer ??

i just follow this code

MessageBox.Show(System.Environment.OSVersion.ToString());

and for XP service pack 3 i get this message

Microsoft Windows NT 5.1.2600 Service Pack 3

Is there any code to detect the exact OS so that i can run the Process by If else clause .
Posted

1 solution

Have a look at the Operating system[^] class
 
Share this 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