1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
|
Public Function GetDiskSpaceFree(ByVal Drive As String) _
As Double
Dim FSO As Object
Dim Drv As Object
Dim SpaceFree As Double
SpaceFree = -1
Drive = UCase$(Left$(Drive, 1))
Set FSO = CreateObject("Scripting.FileSystemObject")
For Each Drv In FSO.Drives
If Drv.DriveLetter = Drive Then
On Local Error Resume Next
SpaceFree = Drv.AvailableSpace
If Err<>0 Then SpaceFree = -1
On Local Error Goto 0
Exit For
End If
Next
GetDiskSpaceFree = SpaceFree
End Function |