isFile()

Function to check whether an object is a File object and whether the file exists. Useful for parsing the results of the Folder method .getFiles().

The function isFile() is located in the file file.jsxinc.

Usage

To check whether a resource is a file object:

var file = new File("C:/myfile.txt");
if(isFile(file))
   //Do something is this is a file object

To check whether the resource is a file object and that the file exists on the file system:

var file = new File("C:/myfile.txt");
if(isFile(file, true))
   //Do something is this is a file object and if the file exists on the file system.

Parameters

Parameter Data type Required Description
file All The object to check. You can parse any kind of object, string or variable to this function.
mustexist Boolean   If set to true the function also checks that the file exists on the file system.

Return values

Value Meaning
true The specified object is a file object. When the second parameter is set to true, this also means that the file exists on the file system.
false The specified object is not a file object. When the second parameter is set to true, this can also mean that the file does not exist on the file system even when the object is a file object.