• Welcome to Jose's Read Only Forum 2023.
 

IFileSystem.DriveExists Method

Started by José Roca, July 14, 2008, 03:03:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the DriveExists method.

JScript


function ReportDriveStatus(drv)
{
   var fso, s = "";
   fso = new ActiveXObject("Scripting.FileSystemObject");
   if (fso.DriveExists(drv))
      s += "Drive " + drv + " exists.";
   else
      s += "Drive " + drv + " doesn't exist.";
   return(s);
}


VBScript


Function ReportDriveStatus(drv)
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If fso.DriveExists(drv) Then
      msg = ("Drive " & UCase(drv) & " exists.")
   Else
      msg = ("Drive " & UCase(drv) & " doesn't exist.")
   End If
   ReportDriveStatus = msg
End Function


PowerBASIC


FUNCTION ReportDriveStatus (BYVAL strDrive AS STRING) AS STRING

   LOCAL fso AS IFileSystem
   LOCAL strMsg AS STRING

   fso = NEWCOM ("Scripting.FileSystemObject")
   IF fso.DriveExists(UCODE$(strDrive)) THEN
      strMsg = "Drive " & UCASE$(strDrive) & " exists."
   Else
      strMsg = "Drive " & UCASE$(strDrive) & " doesn't exist."
   End If
   FUNCTION = strMsg

END FUNCTION