Select a folder for the user, but only for the first time

Hi, I have made a stand-alone audio App.
I want the user to click load and go straight to an example folder, to help find some demo samples. But then, if they choose another folder, it’ll remember that one if they reload the software.
Anybody know how I do that? Basically, is there a Juce way? I guess it should be a folder relative to the main program.

I think the method to use is the PropertySet.

A sample implementation is given in the Projucer (but maybe it is easier from scratch, looks a bit too evolved to me for an example):

I would try to read the last selected file, and if it’s not set or an invalid path, I would open the FileChooser…

Thanks man! I’ll check through my options there.

I’ve decided to use:

FileChooser fc("Select an audio file...", File::getCurrentWorkingDirectory(), "*.wav;*.mp3;*.aif;");

And put the examples next to the App. It seems to work on Windows anyhow.

Ahh, on Mac - If I copy the App to another folder, getCurrentWorkingDirectory() just comes up with the root of my HD, for some reason. Why is that? How do I solve this?
Dave H

The concept of a working directory doesn’t really apply to app bundles. You need to save the value of the last path somewhere in a file on disk (like a preferences file) then read from that file later. Look at the PropertiesFile class.

But I wanted a selection of examples that the user can find as soon as they open the file window? Is that possible.

Maybe I’m not understanding the problem…

How are you distributing your App? Your installer can create a directory somewhere in the users bit of the file system then you can use that location in the constructor of the file chooser. You could also use File::SpecialLocationType::currentApplicationFile to get the location of your app (or exe on Windows).

Your example doesn’t compile but this does File::getSpecialLocation(File::currentApplicationFile)
It gives the interior of the App which is OK, I can go anywhere from there.

I’m planning on selling as a 3rd party distributor. I don’t know how to package it to be honest, I’m used to using the Packagemaker to install plug-ins. I haven’t done an actual App before now.

Wow. PropertySet is really, really useful. Especially with the creation of XML files for saving. Nice work guys! :+1:
I now have the previous ‘save’ AND ‘load’ folders kept separately.

1 Like