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