I set a bost-build copy file and the image is copied in the Resources Folder.
I wanted to load and display a file, so I put this code (in Window1.Open Event):
// Load and display an image
Dim Res_Fldr_FI As FolderItem
Dim An_Img_FI As FolderItem
Res_Fldr_FI = App.ExecutableFile.Parent.Child("Resources")
If Res_Fldr_FI <> Nil Then
// Get a Reference to the image file
An_Img_FI = Res_Fldr_FI.Child("Coquille.png")
// Load that image file
cLogo.Backdrop = Picture.Open(An_Img_FI)
cLogo.Invalidate
End If
Nothing appears where it is due…
What’s wrong ?
An_Img_FI.Exists is False in the Debugger…
Xojo 2021r1.1 / Big Sur / M1
Try using SpecialFolder.Resources?
// Load and display an image
Dim An_Img_FI As FolderItem = SpecialFolder.Resources.Child("Coquille.png")
// Load that image file
If An_Img_FI <> Nil and An_Img_FI.Exists Then
cLogo.Backdrop = Picture.Open(An_Img_FI)
cLogo.Invalidate
End If
Or even simpler:
// Load and display an image
Dim An_Img_FI As FolderItem = SpecialFolder.Resource("Coquille.png")
// Load that image file
If An_Img_FI <> Nil and An_Img_FI.Exists Then
cLogo.Backdrop = Picture.Open(An_Img_FI)
cLogo.Invalidate
End If
Thank you Anthony for the clue.
The image is in the Resources folder of the Application; that is why I used:
Res_Fldr_FI = App.ExecutableFile.Parent.Child("Resources")
Arg: I found App.ExecutableFile, so I do not seek SpecialFolder !
PS: I may be tired because I wrote my answer in French !
That works fine. Thank you Anthony.
1 Like