GetCanonicalPath

Description

Returns the canonical path string of the input path string. This function resolves the absolute path as well as the shorthands or redundant names like "." and "..". It also resolves the case of the drive letter in Windows.

Returns

The resolved file path.

Category

System functions

Function syntax

GetCanonicalPath( path )

See also

FileOpen

History

ColdFusion (2018 release) Update 1: Added the function.

ColdFusion (2016 release) Update 7: Added the function.

Parameters

Parameter

Description

path

Absolute or relative path of a directory or to a file.

Example

<cfscript>
 file1 = createObject("Java", "java.io.File")
 file1="C:/foo/bar/tmp/a.txt/"
 file2="c:\abc\..\abc\file.txt"
 writeOutput(getCanonicalPath(file1))
 writeOutput(getCanonicalPath(file2))
</cfscript>

Output

C:\foo\bar\tmp\a.txt 

C:\abc\file.txt

 Adobe

Get help faster and easier

New user?

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX 2024

Adobe MAX
The Creativity Conference

Oct 14–16 Miami Beach and online

Adobe MAX

The Creativity Conference

Oct 14–16 Miami Beach and online