Write a file in the Temporary folder

I want to add a secure saved state of a ListBox contents.

To do that I create a file in the Temporary folder:

TempTxtName = "Simple Displayer - " + ReplaceAll(NowTemp.SQLDateTime, ":", "-") + ".txt" gTempFI = SpecialFolder.Temporary.Child(TempTxtName)

  1. Is the TempTxtName secure enough to not fall there into a file with the same name ?

  2. Must I keep track of that FolderItem and delete it at Application.Close (Quit) time ?
    Do the OSes deals with the contents of the temporary folder (no on OS X ’cause Xojo left files there) or is it to the developer to do that?

  3. Any more advice(s) from the grounds on this subject ?

TIA.

I would use specialfolder.applicationdata myself actually specialfolder.applicationdata.child().Child().

And yes it’s up to you do remove these files on app end if you want to do that. Placing your file in the temp folder may be subject to disk cleanup tools.

[quote=130124:@Emile Schwarz]1. Is the TempTxtName secure enough to not fall there into a file with the same name ?

  1. Must I keep track of that FolderItem and delete it at Application.Close (Quit) time ?
    Do the OSes deals with the contents of the temporary folder (no on OS X ’cause Xojo left files there) or is it to the developer to do that?[/quote]

  2. Yes, TemptxtName is safe.

  3. The whole content of temporary is deleted upon close.

While I was running my application ?
(no, it can’t be so !)

Sometimes, I get Xojo temporary files in my trash… OS X 10.

[quote=130139:@Emile Schwarz]While I was running my application ?
(no, it can’t be so !)[/quote]

On Windows there are a number of badly behaved cleanup and optimization crappy programs that do shameful things. I would not be surprised if some of these pests messed up the temporary folder. Never, ever use any Windows “speed optimizer”. Most of them are made to be sold, not used.

When apps using /tmp crash without cleaning themselves up you’ll find the files in Recovered Items in the trash after a restart. Normal behavior :slight_smile:

Thanks all.