Launch file from resources folder?

Can a MAS app launch pdf files from it’s own resources folder, or do they need to be copied over to the ApplicationData folder on first run, and then launched from there?

Thank you all in advance.

yes, yes it can
as long as READ ONLY


You can access any files within the Resources folder but you cannot write anything or update anything in the Resources folder.


Thank you both.



OK - this is now bugging me.

The code below works:

[code]Dim fi as FolderItem = SpecialFolder.Desktop.Child(“myPage.html”)

If fi <> Nil Then
Dim s As String = fi.ShellPath

But this doesn’t:

[code]Dim fi as FolderItem = App.ExecutableFile.Parent.Parent.Child(“Resources”).Child(“myPage.html”)

If fi <> Nil Then
Dim s As String = fi.ShellPath

Can anyone help?

Thank you all in advance.

Does myPage.html exist in both the places to which you are referring?

Desktop in the first example and the Resources folder in your second example?

You need to have a CopyFiles build step to copy myPage.html from wherever it actually resides to your Resources folder.


I dragged the html page into the folder containing my project file, (and all the other required files).
I then dragged it from there, into the navigator.

I then used the code above, but no page gets displayed?

No this will not work as the compiled app will not have the file in the actual resources folder.

Wait 5 and I’ll post an example.


How comes all of my image files get copied into the resources folder then?
I do not use a CopFile build step on any of those?

Normally, if you drag a file into the navigator - it gets copied to the resource folder when you build your app.


Images are automatically copied from the IDE to the Resources folder. You will notice that the extension is missing on those files but Xojo works it out somehow. Other files DO NOT work that way!

In the IDE click on the large Insert button, top left of the toolbar.

Select Build Step, Copy Files. That will create an item in the IDE called CopyFiles1. Drag this down and drop it on Build Settings, OS X. After that make sure it is BELOW the Build option (you might have to drag it down one). Then click on it to open it.

In the right hand side of the IDE change the Destination from App Parent Folder to Resources.

Now open Finder and drag the html file into the main window area of the IDE.

That’s it.


Wow - I never knew that - Thanks so much Simon!

I presume that I now do as I was doing - drag the html file into the navigator, and use the same code I had?


since when?

I have text files, image files, html files, etc. etc. all drug into the IDE, and they all work this way

that’s what I thought?

But seeing as how my original code isn’t working - I presume Simon is correct. Are you saying that you can successfully display html files from the resources folder, into an HTMLViewer, without doing what Simon suggested?

If so, do you have any idea what I have done wrong?


OK - I just tried Simons advice.
The html page has been copied into the resources folder, BUT, still refuses to display in the HTMLViewer?

I then tried it my original way, and that DID copy over the files, but still didn’t display the html page in the HTMLViewer.
So it must be a problem with my code?

Check your path. This should work. What value does s have?

I used a MsgBox to display s and it displayed this:

/Users/RichardSummers/Desktop/TestApp\ 2.0/

While “fi” is not likely to be NIL, it may very well not exist. I’d suggest also checking its “.exists” property.