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


#1

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.


#2

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…


#3

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


#4

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.


#5

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?
Thanks.
Dave H


#6

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.


#7

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


#8

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).


#9

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.
Thanks.

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.


#10

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.