The following example illustrates the use of the
FolderExists method.
JScript
function ReportFolderStatus(fldr)
{
var fso, s = fldr;
fso = new ActiveXObject("Scripting.FileSystemObject");
if (fso.FolderExists(fldr))
s += " exists.";
else
s += " doesn't exist.";
return(s);
}
VBScript
Function ReportFolderStatus(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.FileSystemObject")
If (fso.FolderExists(fldr)) Then
msg = fldr & " exists."
Else
msg = fldr & " doesn't exist."
End If
ReportFolderStatus = msg
End Function
PowerBASIC
FUNCTION ReportFolderStatus (BYVAL strFolderSpec AS STRING) AS STRING
LOCAL fso AS IFileSystem
LOCAL strMsg AS STRING
fso = NEWCOM ("Scripting.FileSystemObject")
IF fso.FolderExists(UCODE$(strFolderSpec)) THEN
strMsg = strFolderSpec & " exists."
Else
strMsg = strFolderSpec & " doesn't exist.")
End If
FUNCTION = strMsg
END FUNCTION