cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
DonAIR
Level 6

Go Back a Directory with a string

Pardon if this is a stupid question, but I am looking for a way to get the path one directory up from SRCDIR... for example:

Lets say SRCDIR is set to: "C:\Test1\Test2\Test3"
I am looking to get "C:\Test1\Test2"

I was looking at various built in ways but they all require a start point which I wouldn't have since SRCDIR can be anything.

What I am actually doing is looking for a file, silent.ini and I would prefer to look for it one directory UP from the setup.exe. My current code is below, which checks for the file in the same location.


#define SILENTINSTALLFILE "silent.ini"

if (FindFile ( SRCDIR, SILENTINSTALLFILE, sResult ) = 0) then
DO SOMETHING
else
DO SOMETHING
endif;
Labels (1)
0 Kudos
(2) Replies
DLee65
Level 13

Will a relative path work?

Something like
szPath = SRCDIR ^ ".."

It sounds like the file is 'always' 1 directory up from SRCDIR, so the relative path \..\ should get you there. I was looking to see if there is a way to change this to a absolute path or if InstallScript implements a 'push' 'pop' method for switching directories and that would allow you to get an absolute path. But help does not indicate that this function exists.

The other way I have handled this in the past is using StrGetTokens to parse the path into its parts. I then reform the path without the very last string part. So all you need to know is the number elements in the list object returned by StrGetTokens.
0 Kudos
DonAIR
Level 6

DLee65 wrote:
Will a relative path work?

Something like
szPath = SRCDIR ^ ".."

It sounds like the file is 'always' 1 directory up from SRCDIR, so the relative path \..\ should get you there. I was looking to see if there is a way to change this to a absolute path or if InstallScript implements a 'push' 'pop' method for switching directories and that would allow you to get an absolute path. But help does not indicate that this function exists.

The other way I have handled this in the past is using StrGetTokens to parse the path into its parts. I then reform the path without the very last string part. So all you need to know is the number elements in the list object returned by StrGetTokens.


No that is perfect, I assumed .. didn't work in installshield.
0 Kudos