2010-02-22 7 views

Répondre

0
dim position 
position = InStr("your-path", ":") 

If position > 0 Then 
    ''# absolute path 
else 
    ''# relative path 
end if 
+0

Je tiens à souligner que le; et // sont à la fois java/c/C++/etc. –

+5

La vérification de la présence d'un deux-points n'est pas suffisante. Par exemple, 'C: \ fichier.txt' est un chemin complet alors que' C: fichier.txt' est relatif (voir http://msdn.microsoft.com/fr-fr/library/aa365247(VS.85). aspx # fully_qualified_vs._relative_paths). – Helen

+0

@Helen: excellente information, merci mais ne peut pas comprendre où ce chemin se rapporte? – Sarfraz

1
set oFSO = CREATEOBJECT("Scripting.FileSystemObject") 

relativePath = "" 
absolutePath = "c:\test" 

MsgBox UCase(relativePath) = UCase(oFSO.GetAbsolutePathName(relativePath)) 
MsgBox UCase(absolutePath) = UCase(oFSO.GetAbsolutePathName(absolutePath)) 
+0

Je ne comprends pas comment c'est une réponse à la question? – Spike0xff

-1

Peut-être qu'il serait mieux de cette façon:

FUNCTION IsPathAbsolute(testedPath) 

set oFSO = CREATEOBJECT("Scripting.FileSystemObject") 

IsPathAbsolute = UCASE(testedPath) = UCASE(oFSO.GetAbsolutePathName(testedPath)) 
+2

Ne fonctionnera pas de manière fiable, puisque GetAbsolutePathName normalise également le chemin, par ex. 'C: \ foo \ .. \ bar' sera normalisé en' C: \ bar' – peterchen

Questions connexes