Relative Path in VBScript

-1

I want to associate a XML with an application with VBScript and I need to indicate in the application which directory to read XML , however, as is easy to predict, Path of XML it can not be hardcoded.

Is there any way to VBScript indicate "../PastaAplicacao/Ficheiros/config.xml" with VBScript ?

    
asked by anonymous 31.05.2016 / 13:46

1 answer

0

You can either get the file path and try:

Dim caminhoArquivo, segmentosCaminhoArquivo, nomeArquivo, caminhoPastaAtual

caminhoArquivo = Wscript.ScriptFullName
segmentosCaminhoArquivo = Split(caminhoArquivo, "\")

nomeArquivo = segmentosCaminhoArquivo(UBound(segmentosCaminhoArquivo))
caminhoPastaAtual = Left(caminhoArquivo, Len(caminhoArquivo) - Len(nomeArquivo))

Or even get the current directory when instantiating an object:

Set objShell = CreateObject(“Wscript.Shell”)

caminhoPastaAtual = objShell.CurrentDirectory

From here, you can use the relative path with:

caminhoOutraPasta = caminhoPastaAtual & "..\pastaIrma\"
caminhoOutraPasta2 = caminhoPastaAtual & "pastaFilha"

I hope I have helped \ o /

    
31.05.2016 / 15:10