DiskFree Function (Long) | |
Return the space available on a specified disk.
Namespace:
XSharp.Core
Assembly:
XSharp.Core (in XSharp.Core.dll) Version: 2.21
Syntax FUNCTION DiskFree(
nDrive AS LONG
) AS INT64
public static long DiskFree(
int nDrive
)
Request Example
View SourceParameters
- nDrive
- 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.
Remarks
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.
Examples
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
5 nSpaceNeeded := Integer((RecSize() * ;
6 LastRec()) + Header() + 1)
7 IF DiskFree(cTargetDrive) < nSpaceNeeded
8 lSuccess := FALSE
9 ELSE
10
11 DBCloseArea()
12 FCopy("sales.dbf", cTargetDrive + ":"+ cTargetFile)
13 lSuccess := TRUE
14 ENDIF
15 RETURN lSuccess
See Also