|
-
Oct 18th, 2006, 01:30 AM
#1
Thread Starter
Hyperactive Member
[2.0] Application Questions
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
"Visual Studio .NET 2005/.NET Framework 2.0"
The eyes are the greatest telescopes, one will ever need to study the universe. Let the heart be the tripod, the mind be the shaft, then let the eyes become the lens of that great telescope of which God gave to us all.
-
Oct 18th, 2006, 01:34 AM
#2
Re: [2.0] Application Questions
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.
-
Oct 18th, 2006, 06:43 AM
#3
Re: [2.0] Application Questions
 Originally Posted by ahmad_iam
1) How we can get the total size of the C drive and the free space available.
There is an example here. This is also a good site to bookmark if you are going to be doing work in C#.
-
Oct 18th, 2006, 07:09 AM
#4
Re: [2.0] Application Questions
2) and 3)
VB Code:
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());
}
-
Oct 18th, 2006, 08:13 AM
#5
Re: [2.0] Application Questions
 Originally Posted by ahmad_iam
1) How we can get the total size of the C drive and the free space available.
Use System.IO.DriveInfo Class
 Originally Posted by ahmad_iam
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
Code:
// put "using Microsoft.VisualBasic.Devices"
ComputerInfo myCompInfo = new ComputerInfo();
Console.WriteLine("Physical Memory {0}", myCompInfo.TotalPhysicalMemory );
 Originally Posted by ahmad_iam
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.
Use [code] source code here[/code] tags when you post source code.
My Articles
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|