• Welcome to Jose's Read Only Forum 2023.
 

IDrive.DriveLetter Property

Started by José Roca, July 14, 2008, 05:24:10 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following code illustrates the use of the DriveLetter property:

JScript


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


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


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