Please enable JavaScript to view this site.

Knowledge Base

Navigation: Scripting Language > System

fileexists

We've made some changes. Use 'Ctrl-F5' to clear your browser cache.
Scroll Prev Top Next More

Checks if a file exists. The file extension (ie, .fsp, .lms, etc) must be specified. By default, the entire path will be searched.

 

Supported Product: FDTD, MODE, DEVICE, INTERCONNECT

 

Syntax

Description

out = fileexists("filename");

Returns 1 if the file exists

Returns 0 if the file does not exist.

out = fileexists("c:\temp\file.txt");

Search for a file not in the path

 

Examples

Checks if a file exists before opening it.

filename="simulation.fsp";

if (fileexists(filename)) {

 load(filename);

}

 

Load a simulation project file, if it exists. First check current directory, then check up one directory.

filename="simulation.fsp";

 

if (fileexists(file)) {

 load(filename);

} else {

 file = "../"+file;

 if (fileexists(file)) {

  load(filename);

 } else {

  ?"File not found.";

 }

}

 

See Also

System level, getpath, which, pwd, load, loaddata, write, readdata, currentfilename, rm, exist

Copyright Lumerical Inc. | Privacy | Site Map