This function is used in Python Scripting.


Checks to see if a file or folder at a given path exists.

Note: This function is scoped for Perspective Sessions, but since all scripts in Perspective run on the Gateway, the file must be located on the Gateway's file system. 

Client Permission Restrictions

This scripting function has no Client Permission restrictions.



  • Parameters

String filepath - The path of the file or folder to check.

  • Returns

Boolean - True if the file/folder exists, false otherwise.

  • Scope

Gateway, Vision Client, Perspective Session

Code Examples
Code Snippet
# This basic example shows how the fileExists function is used in its simplest form:
if system.file.fileExists("C:\\temp_file.txt"):
   system.gui.messageBox("Yes, the file exists")
   system.gui.messageBox("No, it doesn't exist")
Code Snippet
# This code uses the fileExists function, along with other system.file.* functions, to prompt the user to confirm that they want to overwrite an existing file.
filename = system.file.saveFile("")
if filename is not None:
   reallyWrite = 1
   if system.file.fileExists(filename):
      overwriteMessage = "File '%s' already exists. Overwrite?"
      reallyWrite = system.gui.confirm(overwriteMessage % filename)
   if reallyWrite:
      system.file.writeFile(filename, "This will be the contents of my new file")

system file fileExists, file.fileExists