Last updated on
Apr 27, 2021
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
Function syntax
GetCanonicalPath( path ) |
See also
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