Author Topic: IDrive.FreeSpace Property  (Read 2830 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.FreeSpace Property
« on: July 14, 2008, 05:19:43 AM »

The following code illustrates the use of the FreeSpace property:

JScript

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

VBScript

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

PowerBASIC

Code: [Select]
FUNCTION ShowDriveLetter (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 " & ACODE$(d.DriveLetter) & ": - "
   s = d & ACODE$(d.VolumeName) & CRLF
   v = d.FreeSpace
   s = s & "Free Space: " & FORMAT$(VARIANT#(v) / 1024)
   s = s & " Kbytes"
   FUNCTION = s

END FUNCTION