Data persistence

I am adding a new feature to a project and I am at the moment I want to add data persistence to it.

More precisely, I want to save the contents of a Recents Menu:

a. The Menu Item Name (easy: it’s a String)
b. The Menu Item Tag: the hard part, this is a FolderItem.

The question is simple:

How do I save to disk a FolderItem (of course, knowing that I will have to read it / restore it).

TIA

PS: in the mean time, I saved the Menu Name (Text) and (Tag) FolderItem’ Path (I forgot which one I used) and this is nice, the “save” part works fine.

Have you checked folderitem.nativepath?

Check out the FolderItem.GetSaveInfo, base64 encode the returned value and save it.

Hi Wayne,

thank you for your answer.

All xxPath (ShellPath, AbsolutePath, NativePath and… URLPath) are noted as Read Only (entries with a locked icon).

BUT: the idea looks nice.

Hi James,

FolderItem.GetSaveInfo

I will read its description more closely.

Thank you for your answer.

[quote=271168:@Emile Schwarz]Hi Wayne,

thank you for your answer.

All xxPath (ShellPath, AbsolutePath, NativePath and… URLPath) are noted as Read Only (entries with a locked icon).

BUT: the idea looks nice.[/quote]

You can use GetFodlerItem to use these to define a folderitem…

http://documentation.xojo.com/index.php/GetFolderItem

hope this helps…
http://www.cjoint.com/c/FFkleMBIsfz

From my FolderItem Preference class:

ToString:
Return EncodeBase64( FolderItem( Value ).GetSaveInfo(nil) )

Constructor:
item = GetFolderItem( DecodeBase64( valueValue ) )

For Mac you can use the OWRecentItem from the Sandbox kit. It uses Apple’s Recent Items mechanism which is also Sandbox Safe.

Thank you all for your answers.

Please notice that the FolderItem have to be saved to disk and created from disk.

I didn’t had a chance to try the previous advices, I will try to do that today.

Cheers

I have to thank Dave S for a different post who inspired me to find another solution.

Save the path as URL in the text file and restore it (GetFolderItem) from there later.