Including Files within App

I am sure this has been covered before, but I am still not getting it (https://forum.xojo.com/7911-write-files-to-executable/18). So I’ll ask.

As an example, I have a bunch of sound files I want to include (bundle) with one particular app. If I drag and drop the folder were they reside into the IDE, they are available as named constants (I think).

  1. What options do I have if I want to re-write them back into a folder within my application folder? Any examples (the simpler the better would be most welcomed).

  2. If I wan to access these sound files within my app, without writing them out to disk, how can I access them from within the app ? As an example, say one of my sound files is “AB.wav”. In my app (within the IDE) it will show as “AB”, and it will recognize it is a sound file. But say I have a drop down with a bunch of names (strings), how can I programmatically use that name string (say “AB”) which I get from the drop down to call out the file (say “AB.wav”). I think I must turn the string into a FolderItem or something, but since I am not retrieving the file from disk (in this case it is within the app itself) I am not sure how to do it (or if I can do it).

I know the second question is very murky, but I am struggling on how to conceptualize this.

Thanks in advanced.

Dont
Write them to SpecialFolders.ApplicationData
Writing to your app bundle is not a good idea and is normally restricted

There’s no built in way to say “give me a list of all the sound files IN my application”
So you write some code
Perhaps a module that lists them by name (code you wrote)

Instead of dragging the sound files to the IDE (and then use these files as constant) you can add post build Copy step where you drag the files and set where you want to find them (for example resources, or a folder within it)

Then while the app is running you can access these files as standard FolderItems with (for example) path like:
dim f as folderItem=App.ExecutableFile.parent.child(“Resources”).child(“myAppSounds”).child(“AB.wav”)
where AB.wav is the file you want to load, myAppSound is a folder within Resources that you setted in the Copy Step.

Norman / Antonio,
I hear you both. I like what Antonio suggests, and have been doing this manually. These applications are for internal consumption and must have everything self contained within their structure. That is to say, they can’t be accessing user folders or appdata folders outside their structure. Reason for that is simple (to us anyways). We have regulations that require that during an audit everything is found in one place. I know this may be “weird” to some, but such is the nature of the industry I work in, it could care less about which PC (Linux, Windows, Mac) is running it. So it is not bound by those rules.

Antonio,
What you reference is the way I am doing it, but manually. I presume you are suggesting some sort of IDE script or post-build script. Do you have a simple example of that? Haven’t done that before, but that definitely sounds like what I want to do.

Thanks again.

Think I got it. “Build Step -> Copy Files”