User Guide Cancel

DirectoryExists

 

Description

Determines whether on-disk or in-memory directory exists.

Returns

Yes, if the specified directory exists; No, otherwise.

Category

System functions

Function syntax

DirectoryExists(path)
DirectoryExists(path)
DirectoryExists(path)

See also

DirectoryCreateDirectoryDeleteDirectoryListDirectoryRename

Parameters

Parameter

Description

path

An absolute on-disk or in-memory path. Alternatively, you can specify IP address as in the following example: DirectoryExists("//12.3.123.123/c_drive/test");

Example

<cfscript>
theDir=GetDirectoryFromPath(GetCurrentTemplatePath());
theFile=theDir & "sheets/Books_AddColumn.xlsx";
path = directoryExists(theFile);
writeoutput("Does the path exists" & "<br>" & path);
</cfscript>
<cfscript> theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); theFile=theDir & "sheets/Books_AddColumn.xlsx"; path = directoryExists(theFile); writeoutput("Does the path exists" & "<br>" & path); </cfscript>
<cfscript>
theDir=GetDirectoryFromPath(GetCurrentTemplatePath()); 
theFile=theDir & "sheets/Books_AddColumn.xlsx";
path = directoryExists(theFile);
writeoutput("Does the path exists" & "<br>" &  path);
</cfscript>

Output

Does the path exist: 
NO

Get help faster and easier

New user?