Saving picture files within a project

I have written the following code to open a picture from a file and store it in Module 1 of my project.

Dim Pictures As New FileType
Dim SelectedPicture As Picture
Pictures.Name =“Picture Files”
Pictures.Extensions = “.jpg”
Dim f As FolderItem =GetOpenFolderItem(Pictures)
SelectedPicture = f.OpenAsPicture

This all works fine, but I want the picture to remain in Module 1 after I have shut down the application so it is still there the next time I open it. Does anybody know how I can achieve this ?

To achieve persistence of any kind of data, you will need to write that data to disk and read it upon next launch of your app. Look at the Xojo examples on writing to disk. It is not difficult.

Following on from Roger’s comment, I would advise the following.

#1 Once a picture has been selected, ‘copy it’ to your app’s data folder within the application support folder, rename it if you need to, so that when your app re-opens it just checks that location.

Learning how to save images is a must. However in this situation, copying the file as opposed to opening it and saving it when your application closes, will save CPU & disk access, speed up the app and also adds a bit of ‘crash protection’.

#2 Store settings like this in your apps data folder of the application support folder. Take a look at specialFolder.applicationData, you then create a subfolder with your application identifier and write data there.