Click to See Complete Forum and Search --> : [2.0] Application Questions
ahmad_iam
Oct 18th, 2006, 01:30 AM
I am going to develop an application in C#.NET 2005 Express Edition, and i want to ask some certain questions and these are as under,
1) How we can get the total size of the C drive and the free space available.
2) How we can get the total size of the RAM and the free space available.
3) How we can determine which operating system is running e.g. NT/XP.
Tell me which method or name space is used to determine all these 3 things.
Thanks
Imran Ahmad Mughal
mar_zim
Oct 18th, 2006, 01:34 AM
You could achieve all those things using WMI. Try to search about WMI in msdn or in google, surely you could find what you're looking for.
Hack
Oct 18th, 2006, 06:43 AM
1) How we can get the total size of the C drive and the free space available.There is an example here (http://csharp-home.com/index/tiki-view_faq.php?faqId=3#q20). This is also a good site to bookmark if you are going to be doing work in C#.
Harsh Gupta
Oct 18th, 2006, 07:09 AM
2) and 3)
System.Management.ManagementClass myManagementClass = new System.Management.ManagementClass("Win32_OperatingSystem");
System.Management.ManagementObjectCollection moc = myManagementClass.GetInstances();
foreach(System.Management.ManagementObject mo in moc)
{
MessageBox.Show("Total RAM: " + mo["TotalVisibleMemorySize"].ToString()) + " KB");
MessageBox.Show("Free RAM: " + (mo["FreePhysicalMemory"].ToString()) + " KB");
MessageBox.Show("OS: " + mo["Caption"].ToString());
}
Shuja Ali
Oct 18th, 2006, 08:13 AM
1) How we can get the total size of the C drive and the free space available. Use System.IO.DriveInfo Class (http://msdn2.microsoft.com/en-us/library/system.io.driveinfo.aspx)
2) How we can get the total size of the RAM and the free space available.Just another way of doing it would be to add a reference to Microsoft.VisualBasic.dll and use something similar to this
// put "using Microsoft.VisualBasic.Devices"
ComputerInfo myCompInfo = new ComputerInfo();
Console.WriteLine("Physical Memory {0}", myCompInfo.TotalPhysicalMemory );
3) How we can determine which operating system is running e.g. NT/XP.Use Environment.OSVersion or if you add a reference to Microsoft.VisualBasic.dll then you can also use ComputerInfo.OSFullName property using the above code.
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.