Drive.GetUsedSpace

number Drive.GetUsedSpace (

string Drive )

Example 1

Used_Space = Drive.GetUsedSpace("C:\\");

Gets the used disk space on the user's "C:\" drive and stores the result in a variable called "Used_Space."

Example 2

how_much = Drive.GetUsedSpace(Read_Drive);

Takes the variable "Read_Drive" that contains a path with a drive letter and stores the used disk space value in how_much.

Example 3

--Specify which drive will be checked
sDrive = "C:";

--Get total size of user's C drive:
nTotalSize = Drive.GetSize(sDrive);

-- Determine if an error occurred.
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
--Get the used space
nUsedSpace = Drive.GetUsedSpace(sDrive);
-- Determine if an error occurred.
error = Application.GetLastError();
if (error ~= 0) then
Dialog.Message("Error", _tblErrorMessages[error], MB_OK, MB_ICONEXCLAMATION, MB_DEFBUTTON1);
else
-- Calculate the drive percentage used, and round up
nPercentageUsed = (nUsedSpace / nTotalSize) * 100;
nPercentageUsed = Math.Ceil(nPercentageUsed);

-- Output percentage to the user
Dialog.Message("","Your drive is "..nPercentageUsed.."% full.");
end
end

This example determines what percentage of the user's C: drive is currently full of data.

See also: Related Actions