• Welcome to Jose's Read Only Forum 2023.
 

IFileSystem.FileExists

Started by José Roca, July 14, 2008, 02:58:29 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

José Roca



The following example illustrates the use of the FileExists method.

JScript


function ReportFileStatus(filespec)
{
   var fso, s = filespec;
   fso = new ActiveXObject("Scripting.FileSystemObject");
   if (fso.FileExists(filespec))
      s += " exists.";
   else
      s += " doesn't exist.";
   return(s);
}


VBScript


Function ReportFileStatus(filespec)
   Dim fso, msg
   Set fso = CreateObject("Scripting.FileSystemObject")
   If (fso.FileExists(filespec)) Then
      msg = filespec & " exists."
   Else
      msg = filespec & " doesn't exist."
   End If
   ReportFileStatus = msg
End Function


PowerBASIC


FUNCTION ReportFileStatus (BYVAL strFileSpec AS STRING) AS STRING

   LOCAL fso AS IFileSystem
   LOCAL strMsg AS STRING

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

END FUNCTION