Megosztás a következőn keresztül:


DISKSPACE( ) Function

Returns the number of bytes available on the default or specified disk drive or volume.

DISKSPACE([cVolumeName [, nType]])

Return Values

Numeric

Parameters

  • cVolumeName
    Specifies the name of the disk drive or volume for which the available space is returned. If you omit cVolumeName, the available space is returned for the default disk drive or volume.
  • nType
    Specifies the type of disk space to retrieve according to following table.
    Value Description
    1 Total amount of space on the volume
    2 (Default) Total amount of free space on the volume.
    3 Total amount of free space available to the user associated with the calling thread.

Remarks

This function is useful for determining whether sufficient space is available to back up files or to execute commands such as SORT that require additional disk space for temporary work files.

The default disk drive or volume is specified with SET DEFAULT.

DISKSPACE( ) returns –1 if there is an error reading the disk drive or volume. On some networks, the value returned by DISKSPACE( ) may not be accurate for large network drives.

Example

The following example uses DISKSPACE( ) to determine whether sufficient disk space is available to perform a sort.

** Check DISKSPACE before sort ** CLOSE DATABASES OPEN DATABASE (HOME(2) + 'Data\testdata') USE customer && Opens Customer table

** Get size of table header ** gnTableHead = HEADER( )

** Calculate size of table ** gnFileSize = gnTableHead + (RECSIZE( ) * RECCOUNT( ) + 1) IF DISKSPACE( ) > (gnFileSize * 3) WAIT WINDOW 'Sufficient diskspace to sort.' ELSE WAIT WINDOW 'Insufficient diskspace. Sort cannot be done.' ENDIF

See Also

HEADER( ) | RECSIZE( ) | SET DEFAULT