Returns the relative path to a directory
#include <File.au3>
_PathGetRelative ( $sFrom, $sTo )
$sFrom | Path to the source directory |
$sTo | Path to the destination file or directory |
Success: | the path to the destination. |
Failure: | the destination and sets @error to non-zero. |
@error: | 1 - $sFrom equals $sTo 2 - An unexpected error occurred with the dll call or the relative path was an empty string |
The returned path will not have a trailing "\", even if it is a root drive returned after a failure.
#include <File.au3>
Example()
Func Example()
Local $sFrom, $sTo, $sPath
$sFrom = @ScriptDir
ConsoleWrite("Source Path: " & $sFrom & @CRLF)
$sTo = @ScriptDir & "\.."
ConsoleWrite("Dest Path: " & $sTo & @CRLF)
$sPath = _PathGetRelative($sFrom, $sTo)
If @error Then
ConsoleWrite("Error: " & @error & @CRLF)
ConsoleWrite("Path: " & $sPath & @CRLF)
Else
ConsoleWrite("Relative Path: " & $sPath & @CRLF)
ConsoleWrite("Resolved Path: " & _PathFull($sFrom & "\" & $sPath) & @CRLF)
EndIf
EndFunc ;==>Example