PowerBasic Museum 2020-A

Legacy Software (PBWIN 9.0+/PBCC 5.0+) => Windows Script Runtime => Source Code => Scripting => FileSystemObject => Topic started by: José Roca on July 14, 2008, 02:56:48 AM

Title: IFileSystem.FolderExists
Post by: José Roca on July 14, 2008, 02:56:48 AM


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