I would like help with creating a .INI style file

Unfortunately, I think I am still stuck in the past. I just purchased XOJO to use to upgrade some old VB apps that haven’t been touched since 2012. Anyway, I have a MP3 database app that looks to a folder to get the Folder.jpg file that represents the Album cover in MP3 albums. My app is often on a different drive than where the Music is stored - so would like to have a way to create an ini style file that contains the UNC path (or traditional path) to the location of the MP3 folder structure. I admit I am still trying to learn the FolderItem logic and coding to it.

:fearful: :scream: :scream: :scream: :scream:

Use a SQLite database, faster and already available

I have already migrated my old VB app along with the 24K MP3 files to the interface. I would just like to include a canvas that has the picture file for the album cover. I would like to include in an INI file a reference like: G:\mp3-files\ to be loaded when the app starts so that I can reference the folders in the mp3-files to load the picture file.

This is already a SQLight database.

As I recall, the contents of an INI file were headers enclosed in square brackets followed by key pairs separated by =

[header]
Key=value
Key=value

[header]
Key=value
Key=value

If that’s the case, you just need to use a TextOutputStream and write each of the lines one at a time.

The Windows Functionality Suite has an IniFileWFS module, if you really need to go down the INI route.

1 Like

you can add an aditional column with the path?

No worries. I will work thru it. I just want a simple way to load a text file upon startup of my app that refers a canvas object to the folder where the photos are located. Since I use the app mobile as well as on the LAN, I need a way to load a different path for different uses of the database app itself. I have no concerns about the SQL side of things - that I can handle. It is just the FolderItem object that I referred to originally. The FolderItem refers to things in a way that I don’t fully know how to work with the old simple path ways from VB.

I always do this:

Var  f as FolderItem
f = new FolderItem ("/path/to/my/file/myfile", FolderItem.PathModes.Native)

Note that this does not create/delete/write to/read from your file/folder, it just gives you a way to refer to it. Then you have things like f.exists, f.IsFolder, .IsReadable etc to decide whether you have an error or not, and can move ahead and use f to create a binary or text input or output stream

see also
https://documentation.xojo.com/api/files/specialfolder.html

as example you get a file from documents like this

Var f As FolderItem = SpecialFolder.Documents.Child("My.ini")
If f.Exists Then

file open
https://documentation.xojo.com/api/files/textinputstream.html#textinputstream-open

file creating
https://documentation.xojo.com/api/files/textoutputstream.html#textoutputstream-create

Thank you both Tim and Marcus. I think this will get me going again in the right direction.

I would also always prefer to use JSON or XML to save config data. Its much easier to read and write because you dont have write your own parser and the type-handling of the variables is better.

i guess he will use ini because it can be written by human :slight_smile: