Skip to content

System.IO.DriveInfo (en)

Alex edited this page Mar 13, 2018 · 1 revision

Provides access to information on a drive.

Examples

The following code example demonstrates the use of the DriveInfo class to display information about all of the drives on the current system.

procedure PrintDrivesInformation;
var
  Drives: TArray<IDriveInfo>;
  DriveInfo: IDriveInfo;
begin
  Drives := TDriveInfo.GetDrives;
  for DriveInfo in Drives do
  begin
    Writeln('Drive ' + DriveInfo.Name);
    Writeln('  Drive type: ' + DriveInfo.DriveType.ToString);

    if DriveInfo.IsReady then
    begin
      Writeln('  Volume label: '+ DriveInfo.VolumeLabel);
      Writeln('  File system: '+ DriveInfo.DriveFormat);
      Writeln('  Available space to current user: '+ DriveInfo.AvailableFreeSpace.ToString + ' bytes');
      Writeln('  Total available space: ' + DriveInfo.TotalFreeSpace.ToString + ' bytes');
      Writeln('  Total size of drive: ' + DriveInfo.TotalSize.ToString + ' bytes');
      Writeln('');
    end;
  end;
end;

Clone this wiki locally