This website uses cookies. By clicking Accept, you consent to the use of cookies. Click Here to learn more about how we use cookies.
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
- Revenera Community
- :
- InstallShield
- :
- InstallShield Forum
- :
- Re: Go Back a Directory with a string
Subscribe
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Subscribe
- Mute
- Printer Friendly Page
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2014
01:22 PM
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.
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;
(2) Replies
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2014
02:31 PM
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.
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.
- Mark as New
- Subscribe
- Mute
- Permalink
- Report Inappropriate Content
‎Jan 28, 2014
02:41 PM
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.