Where are my Resources?

I am shelling out to tar.exe to compress some data.
I have a Folder called Resources relative to my Xojo project file, but within the project I do not have a folder called Resources.

In order to get the shell path to the resource I am using

Dim tarPath As FolderItem = GetFolderItem("Resources")
tarPath = tarPath.Child("tar.exe")

Resources resolves, but the child returns nil.

  • Am I suppose to put a post build ‘copy’ in my project to copy the all the ‘Resources’ to the build folder?

  • Should I create a folder in the IDE / Project called Resources and copy ‘stuff’ there?

If tarPath.Child returns Nil then that suggests that tarPath doesn’t exist.

Dim tarPath As FolderItem = GetFolderItem("Resources")
dim exePath as FolderItem = tarPath.Child("tar.exe")

tarPath not nil
exePath is nil.

Are you getting nil when you dim exePath? or when you trying to use exePath?
I guess your folderitem is not the correct path to your exe.

Right, exePath will be Nil if tarPath does not exist.

Yes. Otherwise, once the project is built, this folder will not be where you expect it to be.

No.

Try SpecialFolder.Resources instead of GetFolderItem("Resources")

1 Like

but like i said… Resources is NOT nil.

That a folderitem is non-nil does not imply that the corresponding file or folder actually exists.

Don’t focus on this.

For example, try this code:

Dim tarPath As FolderItem = GetFolderItem("this_does_not_exist")
Dim exePath As FolderItem = tarPath.Child("tar.exe")

MessageBox tarPath.NativePath
MessageBox exePath.NativePath

this_does_not_exist doesn’t exist, and tar.exe is not inside that. I don’t get nil with the code above.

How/where are you getting Nil?

In fact even this isn’t working…

Dim ResourcePath As FolderItem = GetFolderItem("MyAppName Resources")
Dim TarPath as FolderItem

if ResourcePath <> nil then
  tarPath = ResourcePath.Child("tar.exe")
  if TarPath = nil then
    MsgBox("Wha?")  /// This is where I am.
  end if
else
  MsgBox("Wha?")
end if

Works here with macOS 13.6.7
Tested Xojo2019r3.2 and Xojo2024r2.1
Edit: can’t run 2019r1.1 here for desktop

Decisions Decisions Desicions!

Dim ResourcePath As FolderItem = GetFolderItem(“Resources”) // Nope docs wrong.
Dim ResourcePath As FolderItem = GetFolderItem(“DebugMyAppName Resources”) // If debug
Dim ResourcePath As FolderItem = GetFolderItem(“MyAppName Resources”) // if not debug

What’s wrong with SpecialFolder.Resources?

2 Likes

You should use the proper app resources and the copy automation steps. Your life would be easier.

https://documentation.xojo.com/topics/build_automation/introduction.html#topics-build-automation-introduction-copy-files

1 Like

I need help about resources and automations. I am a developer and learning this to help my client’s chatbots. Please can some one do a zoom meeting with me?

hello still waiting for the reply please I will be very thankful to you :pray:

The links above are not the answers ?

If so, explain what you want to do. Details.