• Welcome to Powerbasic Museum 2020-B.
 

News:

Forum in repository mode. No new members allowed.

Main Menu

IDrive.AvailableSpace Property

Started by José Roca, July 14, 2008, 05:25:49 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code illustrates the use of the AvailableSpace property:

JScript


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


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


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