Windows Phone Developers

Wednesday, April 30, 2008

Get Free Disk Space in all drives using VB.Net

Get Available Disk Space using VB.Net


Sub GetSpaceInDrives()

'Dim oDinfo As DriveInfo

Dim oDrvs() As DriveInfo = DriveInfo.GetDrives

For Each Drv In oDrvs

If Drv.IsReady Then

MsgBox(Drv.Name & " " & Drv.AvailableFreeSpace.ToString)

End If

Next

End Sub

The statement

Dim oDrvs() As DriveInfo = DriveInfo.GetDrives

retrieves the drive names of all logical drives on a computer.

The IsReady property returns true if the drive is ready; false if the drive is not ready. If this check is not done then you will get System.IO.IOException was unhandled Message="The device is not ready. " exception.

AvailableFreeSpace property indicates the amount of free space available on the drive. Note that this number may be different from the TotalFreeSpace number because this property takes into account disk quotas

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment