Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

exists

exists

Returns a value indicating whether the specified file or directory exists.

Method of

File object

Syntax

boolean exists( FileSpecObject target )

Parameters

The exists method has the following parameters:

target
A FileSpecObject representing the file or directory being tested for existence.

Returns

A boolean value specifying whether the file or directory does indeed exist or does not.

Example

f = getFolder( "Program", "sample.txt" );
if ( File.exists(f) ) // do something with the file

Document Tags and Contributors

 Contributors to this page: Sheppy, trevorh, Fredchat, Rod Whiteley
 Last updated by: Sheppy,