Databases Reference
In-Depth Information
FIGURE 2.24 The status of a network drive.
Set FSO = New FileSystemObject
Set SpecDrive = FSO.GetDrive(Drive$)
DriveFreeSpace = SpecDrive.FreeSpace
'We are done here
Exit Function
'Error Handling
Drive_Unavailable:
DriveFreeSpace = 0
End Function
Function DriveTotalSize(ByVal Drive$) As Single
Dim FSO As FileSystemObject
Dim SpecDrive As Drive
On Error GoTo Drive_Unavailable
Set FSO = New FileSystemObject
Set SpecDrive = FSO.GetDrive(Drive$)
DriveTotalSize = SpecDrive.TotalSize
'We are done here
Exit Function
'Error Handling
Drive_Unavailable:
DriveTotalSize = 0
End Function
Notice that, if the drive selected has become unavailable, the values returned for free space or total
size are set to 0 by the error-handling mechanisms of the functions. When dealing with files, some
properties that a user might wish to read are: (1) attributes, (2) when last modified, (3) type, and
(4) size. If a routine were required to append information to files, a function to ensure that a file's
attributes were not set to read only would be useful. If a file were to be replaced by a routine, perhaps
the routine should check when that file was last modified. Functions to perform these functions are listed
below.
Function FileSize(ByVal FileWithPath$) As Single
Dim FSO As FileSystemObject
Dim FileSpec As File
On Error GoTo File_Unavailable
Set FSO = New FileSystemObject
Search WWH ::




Custom Search