Function Reference


Removes elements of a file path according to special strings inserted into that path

#include <WinAPIShPath.au3>
_WinAPI_PathCanonicalize ( $sFilePath )


$sFilePath The path to be canonicalized.

Return Value

Success: The canonicalized path.
Failure: The original $sFilePath parameter, call _WinAPI_GetLastError() to get extended error information.


This function allows the user to specify what to remove from a path by inserting special character sequences
into the path. The ".." sequence indicates to remove a path segment from the current position to the previous path
segment. The "." sequence indicates to skip over the next path segment to the following path segment. The root
segment of the path cannot be removed.

If there are more ".." sequences than there are path segments, the function returns just the root, "\".

See Also

Search PathCanonicalize in MSDN Library.


#include <WinAPIShPath.au3>

Local $aPath[5] = ['A:\Dir1\.\Dir2\..\Dir3', 'A:\Dir1\..\Dir2\.\Dir3', 'A:\Dir1\Dir2\.\Dir3\..\Dir4', 'A:\Dir1\.\Dir2\.\Dir3\..\Dir4\..', 'A:\..']

For $i = 0 To 4
    ConsoleWrite($aPath[$i] & ' => ' & _WinAPI_PathCanonicalize($aPath[$i]) & @CRLF)