Create a FolderItem (with Xojo 2021r2.1)

The project (or application) is shared in a zip document with support files (stored in their own folder) that have to be in a SpecialFolders location.

I do not found my way to create a FolderItem, so I can copy the support folder at its destination (on the first run).

Your help is welcome.

http://docs.xojo.com/FolderItem.CreateFolder

Is this create a FolderItem to an already existing Folder with Data beside the running application ?

This keeps being asked.
Don’t try to amend or create files beside the running app, unless you are CERTAIN that the app is not in Program Files or Applications folder.
The OS will not allow it unless you make system changes.
Its no use at all for an app you want someone else to use.

Put your files in ApplicationData or Documents.

And it would also break the code signature.

…and that is not what I asked.

Here’s a screen shot (the project and the support folder) (1):

image

At project run time, I ant, in App.Open, copy the folder named “SQL Help Files” into “ApplicationData”.

To achieve that, I need to have a FolderItem Reference to that folder. What was very easy to do in standard API (GetFolderItem("") if my memory is correct-.

(1). At distribution time, it is a zip file who holds either the project and the support folder (the screen shot) OR the Application and the support folder.
So, no, I do not want to write in the Application folder.

I hope I am 100% clear now.

Like Tim suggested, this creates a folder that you can then copy your .zip file into, or un-zip its contents into:

Var myDataFolder As FolderItem = SpecialFolder.ApplicationData.Child("MyFolder")
myDataFolder.CreateFolder

When will you distribute a Xojo project?

For distributing a compiled application, the SQL Help Files should not really be in Applications either.
There are 4 files in there?

Rename them to have a txt extension, and drag them into your project
At run time, check if your target folder exists in Application Support
If no, create it as shown above.

Then use a text or binarystream to copy the 4 files into it from specialfolder.resources , but with the correct name, if they do not exist

I never say I wanted to copy anything in the Application folder. (this time).

Inside the folder, there is a txt file and a folder with 80 rtf files.

The goal was to place them in Application Support at first run using CopyTo.

When will you distribute a Xojo project?
As soon as I finished it …

Here’s a rough code that apparently works (I will test that in the afternoon):


Var Support_FI As FolderItem
Var App_Supp_FI As FolderItem

App_Supp_FI = SpecialFolder.ApplicationData.Child("www.w3schools.com-sql")

If Not App_Supp_FI.Child("SQL Help Files").Exists Then
  // Get a reference to the SQL Help Files…
  Support_FI = GetFolderItem("SQL Help Files")
  
  // Copy them to App_Supp_FI
  Support_FI.CopyTo(App_Supp_FI)
End If