Obtient le chemin relatif d'un r�pertoire
#include <File.au3>
_PathGetRelative ( $sFrom, $sTo )
$sFrom | Chemin vers le r�pertoire source |
$sTo | Chemin vers le fichier ou le r�pertoire de destination |
Succ�s: | Retourne le chemin vers la destination. |
�chec: | Retourne la destination et d�finit @error <> 0. |
@error: | 1 - $sFrom est �gal � $sTo 2 - Une erreur inattendue s'est produite � l'appel de la dll ou le chemin relatif �tait une cha�ne vide |
Le chemin retourn� ne se terminera pas par "\", m�me si il est racine d'un disque retourn� apr�s une erreur.
#include <File.au3> Example() Func Example() Local $sFrom, $sTo, $sPath Local $sWow64 = "" If @AutoItX64 Then $sWow64 = "\Wow6432Node" Local $sFile = RegRead("HKEY_LOCAL_MACHINE\SOFTWARE" & $sWow64 & "\AutoIt v3\AutoIt", "InstallDir") $sFrom = @ScriptDir ConsoleWrite("Source Path: " & $sFrom & @CRLF) $sTo = $sFile & "\autoit3.exe" 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