So I read the prior post “Can’t locate resources while in debug mode?” but I had some questions that were not quite answered (or need further clarification).
Specifically, I saw that specialfolder seems to be a potential solution, but I am a bit confused as to how that works.
I specifically need to access certain pictures in a folder. How does specialfolder work with this? I am understanding that specialfolder enables access to a specific area (e.g., specialfolder.desktop gives access to the desktop items), but how do I use that to access my pictures (e.g., “1.png”)?
Where are they?
If you have them in a folder called BING on the desktop, then
var f as folderitem = specialfolder.desktop.child("BING").child("1.png")
(although its is best to get the BING folder first and ensure that works, before looking for the children)
if you have created a folder called 'HanLeeSoftware" in specialfolder.applicationdata on startup or install, then
var f as folderitem = specialfolder.applicationdata.child("HanLeeSoftware").child("1.png")
and the same kind of thing for documents.
When you build a Xojo App, it creates 2 “special folders” with it and put there resources it needs, the “Libs”, where it puts the libraries it needs to load, and the “Resources”, where it puts miscellaneous things as images and where users adds user contents too. Those places are intended to be read only.
To copy extra content into the resources folder you use the “Copy build step” that you can add in the “Build Settings” in the Navigator.
To access a file there you just get a FolderItem reference to it as
Var myImage As FolderItem = SpecialFolder.Resource("myImage001.png")
If you need read-write acess to any file, do as Jeff said, copy them (code those actions) from your resources folder to a read-write proper place as a folder (that you need to create) like:
Var writableAppDataFolder As FolderItem = SpecialFolder.ApplicationData.Child("MyCompany").Child("MyAppWhatever")
Thank you so much for your responses! These were exactly the type of clarifications I was looking for and were very helpful!