Results 1 to 5 of 5

Thread: [2.0] Application Questions

  1. #1

    Thread Starter
    Hyperactive Member ahmad_iam's Avatar
    Join Date
    Jun 2005
    Location
    Pakistan
    Posts
    265

    Lightbulb [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.

  2. #2
    Frenzied Member mar_zim's Avatar
    Join Date
    Feb 2004
    Location
    Toledo Cebu City.
    Posts
    1,416

    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.

  3. #3
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: [2.0] Application Questions

    Quote 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#.

  4. #4
    Smitten by reality Harsh Gupta's Avatar
    Join Date
    Feb 2005
    Posts
    2,938

    Re: [2.0] Application Questions

    2) and 3)
    VB Code:
    1. System.Management.ManagementClass myManagementClass = new System.Management.ManagementClass("Win32_OperatingSystem");
    2.  
    3. System.Management.ManagementObjectCollection moc = myManagementClass.GetInstances();
    4.  
    5. foreach(System.Management.ManagementObject mo in moc)
    6. {
    7.     MessageBox.Show("Total RAM: " + mo["TotalVisibleMemorySize"].ToString()) + " KB");
    8.     MessageBox.Show("Free RAM: " + (mo["FreePhysicalMemory"].ToString()) + " KB");
    9.     MessageBox.Show("OS: " + mo["Caption"].ToString());
    10. }
    Show Appreciation. Rate Posts.

  5. #5
    Shared Member
    Join Date
    May 2005
    Location
    Kashmir, India
    Posts
    2,277

    Re: [2.0] Application Questions

    Quote 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

    Quote 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 );

    Quote 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
  •  



Click Here to Expand Forum to Full Width