Hi Alain, Use System.Management namespace. Here is a quick sample:
Public Function GetDiskSpace() As System.UInt64
Dim diskClass As _
New System.Management.ManagementClass("Win32_LogicalDisk")
Dim disks As System.Management.ManagementObjectCollection = _
diskClass.GetInstances()
Dim disk As System.Management.ManagementObject
Dim space As System.UInt64
For Each disk In disks
If CStr(disk("Name")) = "C:" Then
space = CType(disk("FreeSpace"), System.UInt64)
End If
Next disk
Return space
End Function
Public Function GetDiskSpace() As System.UInt64
Dim diskClass As _
New System.Management.ManagementClass("Win32_LogicalDisk")
Dim disks As System.Management.ManagementObjectCollection = _
diskClass.GetInstances()
Dim disk As System.Management.ManagementObject
Dim space As System.UInt64
For Each disk In disks
If CStr(disk("Name")) = "C:" Then
space = CType(disk("FreeSpace"), System.UInt64)
End If
Next disk
Return space
End Function
I guess Alain was interested in what namespace, class and method to use. It's cool how easy it is to grab a C# concept from an equivalent VB.NET code :-) Appan
ASP.NET Team
This posting is provided "AS IS" with no warranties, and confers no rights.
clem_alain
Member
35 Points
7 Posts
Size available on a drive
Dec 26, 2003 01:28 PM|LINK
appana
Participant
1725 Points
343 Posts
Microsoft
Re: Size available on a drive
Dec 27, 2003 01:14 AM|LINK
Public Function GetDiskSpace() As System.UInt64 Dim diskClass As _ New System.Management.ManagementClass("Win32_LogicalDisk") Dim disks As System.Management.ManagementObjectCollection = _ diskClass.GetInstances() Dim disk As System.Management.ManagementObject Dim space As System.UInt64 For Each disk In disks If CStr(disk("Name")) = "C:" Then space = CType(disk("FreeSpace"), System.UInt64) End If Next disk Return space End FunctionRefer to Finding the Amount of Disk Space Available for more information. Hope this helps, AppanThis posting is provided "AS IS" with no warranties, and confers no rights.
clem_alain
Member
35 Points
7 Posts
Re: Size available on a drive
Dec 27, 2003 09:55 PM|LINK
KraGiE
Star
14567 Points
2926 Posts
Re: Size available on a drive
Dec 29, 2003 06:53 AM|LINK
Public Function GetDiskSpace() As System.UInt64 Dim diskClass As _ New System.Management.ManagementClass("Win32_LogicalDisk") Dim disks As System.Management.ManagementObjectCollection = _ diskClass.GetInstances() Dim disk As System.Management.ManagementObject Dim space As System.UInt64 For Each disk In disks If CStr(disk("Name")) = "C:" Then space = CType(disk("FreeSpace"), System.UInt64) End If Next disk Return space End Functionironic finding that in a c# board. :)appana
Participant
1725 Points
343 Posts
Microsoft
Re: Size available on a drive
Dec 29, 2003 06:22 PM|LINK
This posting is provided "AS IS" with no warranties, and confers no rights.