Author Topic: IDrive.AvailableSpace Property  (Read 3684 times)

0 Members and 1 Guest are viewing this topic.

Offline José Roca

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

The following code illustrates the use of the AvailableSpace property:

JScript

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

VBScript

Code: [Select]
Function ShowAvailableSpace(drvPath)
   Dim fso, d, s
   Set fso = CreateObject("Scripting.FileSystemObject")
   Set d = fso.GetDrive(fso.GetDriveName(drvPath))
   s = "Drive " & UCase(drvPath) & " - "
   s = s & d.VolumeName   & "<BR>"
   s = s & "Available Space: " & FormatNumber(d.AvailableSpace/1024, 0)
   s = s & " Kbytes"
   ShowAvailableSpace = s
End Function

PowerBASIC

Code: [Select]
FUNCTION ShowAvailableSpace (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(UCODE$(drvPath)))
   s = "Drive " & UCASE$(drvPath) & " - "
   s = d & ACODE$(d.VolumeName) & CRLF
   v = d.AvailableSpace
   s = s & "Available Space: " & FORMAT$(VARIANT#(v) / 1024)
   s = s & " Kbytes"
   FUNCTION = s

END FUNCTION