Boworr
27th March 2006 08:22 UTC
Finding the name of a random directory to place a file
Hi,
I have an application that installs an add-on into an existing directory but also needs to place one file into a directory with a random name. This means I can't hard code the directory but need to find it and then potentially ask the user to pick which one they want to use because there may be more than one.
e.g.
installdir\
interface\
add-on-goes-here\
account\
abc\
single-file-goes-here
xyz\
or-maybe-here
95% of the time there will be just one directory under \account so how can I read the directories under \account and then use that as an installdir for this one file? If there are two directories, how would I prompt the user to pick on of them
Afrow UK
27th March 2006 14:22 UTC
Use FindFirst, FindNext and FindClose to loop through files and folders. To check if a found name is the name of a folder, use IfFileExists "$path\$folder\*.*" ...
You can use the PopupListBox plugin to display a list of directories for the user to select, or you can create a custom InstallOptions dialog.
-Stu
Afrow UK
27th March 2006 14:29 UTC
Forgot to mention... I also have an EmbeddedListBox plugin which displays an embedded dialog containing a list box. The list box can be customised with columns and column headers and/or check boxes. This plugin however isn't on the Wiki yet.
Benefits of using both plugins (PopupListBox/EmbeddedListBox) rather than InstallOptions is that list box items are passed via the NSIS stack which in theory has an unlimited size for the amount of data we tend to use. InstallOptions requires you to write list box items in a format as a single string, which means you are limited to 1023 characters (or 8191 if using the special makensis build).
-Stu