findfile (AutoLISP)

Searches the AutoCAD library and trusted paths for the specified file or directory

(findfile filename)

The findfile function makes no assumption about the file type or extension of filename. If filename does not specify a drive/directory prefix, findfile searches the AutoCAD library and trusted paths. If a drive/directory prefix is supplied, findfile looks only in that directory.

Arguments

filename

Name of the file or directory to be searched for.

Return Values

A string containing the fully qualified file name; otherwise nil, if the specified file or directory is not found.

The file name returned by findfile is suitable for use with the open function.

Examples

If the current directory is / AutoCAD and it contains the file abc.lsp, the following function call retrieves the path name:

Command: (findfile "abc.lsp")

"C:\\Program Files\\Autodesk\AutoCAD\\abc.lsp"

If you are editing a drawing in the / AutoCAD/drawings directory, and the acad environment variable is set to / AutoCAD/support, and the file xyz.txt exists only in the / AutoCAD/support directory, then the following command retrieves the path name:

Command: (findfile "xyz.txt")

"C:\\Program Files\\Autodesk\AutoCAD\\support\\xyz.txt"

If the file nosuch is not present in any of the directories on the library or trusted search paths, findfile returns nil:

Command: (findfile "nosuch")

nil