Class or code to calculate Free & Used HD Space

  • Thread starter Thread starter Sam Learner
  • Start date Start date
S

Sam Learner

Hi Everyone,
I thought in .NET there would be like a "Drive" class to allow obtain
specific information about Drives, but it looks like not.

I need to scan a Drive and Obtain (Free and Used disk space) information...
similarly to what the CleanUP disk wizard does.
Can anyone help? may be some sample code, or a class?
thanks in advance,

SJ
 
Sam,

Try this sample wich was original from Steve Hoag in this newsgroup, which I
changed a little bit.
\\\
Public Module main
Public Sub main()
Dim LogicalDisk As _
New System.Management.ManagementClass("Win32_LogicalDisk")
Dim disks As System.Management.ManagementObjectCollection = _
LogicalDisk.GetInstances()
Dim disk As System.Management.ManagementObject
For Each disk In disks
If disk("Name").ToString = "C:" Then
MessageBox.Show(disk("FreeSpace").ToString)
End If
Next disk
End Sub
End Module
///

I hope this helps?

Cor
 
Thank you so much, I only one question, What file do I use to reference the
System.Management.* Namespace ?
I pasted your code in a project, but I got class undefined error.
Please help
Thanks,
SJ
 
Sam,

Just open project->add reference->and choose than system.management, and
than select it and say ok.

That is all.

Cor
 
Thank you so much,
SJ

Cor Ligthert said:
Sam,

Just open project->add reference->and choose than system.management, and
than select it and say ok.

That is all.

Cor
 

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