Author Topic: IDrive.TotalSize Property  (Read 3073 times)

0 Members and 1 Guest are viewing this topic.

Online José Roca

  • Administrator
  • Hero Member
  • *****
  • Posts: 2517
  • User-Rate: +209/-0
  • Gender: Male
IDrive.TotalSize Property
« on: July 14, 2008, 05:09:28 AM »

The following code illustrates the use of the TotalSize property:

JScript

Code: [Select]
function ShowSpaceInfo(drvPath)
{
   var fso, d, s;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   d = fso.GetDrive(fso.GetDriveName(drvPath));
   s = "Drive " + drvPath + " - ";
   s += d.VolumeName + "<br>";
   s += "Total Space: "+ d.TotalSize/1024 + " Kbytes <br>";
   s += "Free Space:   " + d.FreeSpace/1024 + " Kbytes";
   return(s);
}

VBScript

Code: [Select]
Function ShowSpaceInfo(drvpath)
   Dim fso, d, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(drvpath)))
   s = "Drive " & d.DriveLetter & ":"
   s = s & vbCrLf
   s = s & "Total Size: " & FormatNumber(d.TotalSize/1024, 0) & " Kbytes"
   s = s & vbCrLf
   s = s & "Available: " & FormatNumber(d.AvailableSpace/1024, 0) & " Kbytes"
   ShowSpaceInfo = s
End Function

PowerBASIC

Code: [Select]
FUNCTION ShowSpaceInfo (BYVAL drvPath AS STRING) AS STRING

   LOCAL fso AS IFileSystem
   LOCAL d AS IDrive
   LOCAL s AS STRING
   LOCAL v AS VARIANT
   
   fso = NEWCOM "Scripting.FileSystemObject"
   d = fso.GetDrive(fso.GetDriveName(fso.GetAbsolutePathName(UCODE$(drvpath))))
   s = "Drive " & ACODE$(d.DriveLetter) & ": " & $CRLF
   s = d & ACODE$(d.VolumeName)
   s = s & $CRLF
   v = d.get_TotalSize
   s = s & "Total Size: " & FORMAT$(VARIANT#(v) / 1024) & " Kbytes"
   s = s & $CRLF
   v = d.AvailableSpace
   s = s & "Available: " & FORMAT$(VARIANT#(v) / 1024) & " Kbytes"
   FUNCTION = s

END FUNCTION