Click or drag to resize

DiskFree Function (Long)

Return the space available on a specified disk.

Namespace:  XSharp.Core
Assembly:  XSharp.Core (in XSharp.Core.dll) Version: 2.19
	nDrive AS LONG
) AS INT64
Request Example View Source


Type: Long
The number of the disk drive to query, where 1 is drive A, 2 is B, 3 is C, and so on.

Return Value

Type: Int64
The number of bytes of empty space on the specified disk drive.
DiskFree() determines the number of available bytes remaining on the specified disk drive.
It is useful when copying or sorting to another drive to determine if there is enough space available before initiating the operation.
This example is a function that demonstrates the use of DiskFree() to back up a database file to another drive:
 1FUNCTION BackUp(cTargetFile, cTargetDrive)
 2    LOCAL nSpaceNeeded
 3    LOCAL lSuccess := FALSE
 4    // Calculate the size of the open file
 5    nSpaceNeeded := Integer((RecSize() * ;
 6                    LastRec()) + Header() + 1)
 7    IF DiskFree(cTargetDrive) < nSpaceNeeded
 8        lSuccess := FALSE
 9    ELSE
10        // Close the database file before copying
11       DBCloseArea()
12        FCopy("sales.dbf", cTargetDrive + ":"+ cTargetFile)
13        lSuccess := TRUE
14    ENDIF
15    RETURN lSuccess
See Also