PC Review


Reply
Thread Tools Rate Thread

Class or code to calculate Free & Used HD Space

 
 
Sam Learner
Guest
Posts: n/a
 
      12th Nov 2004
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



 
Reply With Quote
 
 
 
 
Cor Ligthert
Guest
Posts: n/a
 
      12th Nov 2004
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

"Sam Learner" <(E-Mail Removed)>

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



 
Reply With Quote
 
Sam Learner
Guest
Posts: n/a
 
      12th Nov 2004
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

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:eLgwN%(E-Mail Removed)...
> 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
>
> "Sam Learner" <(E-Mail Removed)>
>
>> 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
>>
>>
>>

>
>



 
Reply With Quote
 
Cor Ligthert
Guest
Posts: n/a
 
      12th Nov 2004
Sam,

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

That is all.

Cor
"Sam Learner" <(E-Mail Removed)>

> 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
>
> "Cor Ligthert" <(E-Mail Removed)> wrote in message
> news:eLgwN%(E-Mail Removed)...
>> 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
>>
>> "Sam Learner" <(E-Mail Removed)>
>>
>>> 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
>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
Sam Learner
Guest
Posts: n/a
 
      12th Nov 2004
Thank you so much,
SJ

"Cor Ligthert" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Sam,
>
> Just open project->add reference->and choose than system.management, and
> than select it and say ok.
>
> That is all.
>
> Cor
> "Sam Learner" <(E-Mail Removed)>
>
>> 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
>>
>> "Cor Ligthert" <(E-Mail Removed)> wrote in message
>> news:eLgwN%(E-Mail Removed)...
>>> 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
>>>
>>> "Sam Learner" <(E-Mail Removed)>
>>>
>>>> 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
>>>>
>>>>
>>>>
>>>
>>>

>>
>>

>
>



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Raxco PD + W2K + Offline defrag + large cont. free space ->insufficient space msg Poutnikq Microsoft Windows 2000 File System 1 17th Dec 2007 12:46 PM
Free Space Error Code OX80070070 =?Utf-8?B?R2FyeQ==?= Windows Vista Installation 4 5th Mar 2007 05:08 PM
DVD/CD-RW blank - file system unknow, used space 0, free space 0 =?Utf-8?B?UGV0ZQ==?= Windows XP Help 0 18th Nov 2006 08:03 PM
Strange Problem; Plenty of free space but File->SaveAs says not enough disk space Al Dykes Windows XP General 0 13th Sep 2004 02:53 AM
XP Low Disk Space keeps showing up yet plenty of free space left Jim Windows XP Performance 2 30th Jan 2004 08:56 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:16 AM.