Detecting total and free disk/memory space

  • Thread starter Thread starter RobinSword
  • Start date Start date
R

RobinSword

Hi there!

I want my VB.NET-program to detect the total and used amount of disk
space and memory of the system. How can I do that?
I know there is WMI, but I don't know which SELECT-Statement I have to
build in order to get these information.

Best regards
RobinSword
 
Robin,

RobinSword said:
I want my VB.NET-program to detect the total and used amount of disk
space and memory of the system. How can I do that?
I know there is WMI, but I don't know which SELECT-Statement I have to
build in order to get these information.

Add a reference to "System.Management.dll".

\\\
Imports System.Management
..
..
..
Dim disk As New ManagementObject("Win32_LogicalDisk.DeviceID=""C:""")
Dim p As PropertyData
For Each p In disk.Properties
Console.WriteLine("{0} = {1}", p.Name, p.Value)
Next p
///

<URL:http://www.planet-source-code.com/vb/scripts/ShowCode.asp?txtCodeId=842&lngWId=10>
 
This is probably a cheating way to accomplish this but here's how I've
done it in the past:

FileSys = CreateObject("Scripting.FileSystemObject")
Try
Drv = FileSys.GetDrive("C:")

Dim lAvailableSpace As Long
lAvailableSpace = Drv.AvailableSpace

Dim lTotalSpace As Long
lTotalSpace = Drv.TotalSize
Finally
Drv = Nothing
End Try

Hope this helps,
Brian Swanson

RobinSword said:
Hi there!

I want my VB.NET-program to detect the total and used amount of disk
space and memory of the system. How can I do that?
I know there is WMI, but I don't know which SELECT-Statement I have to
build in order to get these information.

Best regards
RobinSword
 
Thanks, I now use the WMI-method of Herfried K. Wagner.
Is there somewhere a list available of all WM-Tables and -Properties
one can query? I desperately search for such a list!!

I also want to know the amount of free system-RAM. Any idea?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top