Our full technical support staff does not monitor this forum. If you need assistance from a member of our staff, please submit your question from the Ask a Question page.


Log in or register to post/reply in the forum.

USR Drive, Delete oldest file


ryan42 Sep 29, 2015 05:07 AM

Hi,

I'm wondering which file the FileList("USR",fileName(1)) instruction will return. If I have 100 files all created 1 hour apart, if I use this instruction something like this...

If settings.USRDriveFree < 1000 Then
'delete the oldest files
FileList("USR",fileToDelete(1))
FileManage(fileToDelete(1),8)
EndIf

will FileList() return the oldest file to delete or is it random?

Cheers
Ryan


JDavis Sep 29, 2015 08:39 PM

I believe it is not random. Depending on how you name files, it might be true that the first file is the oldest.

The safe way to handle it is to use the FileTime instruction to check the timestamps of your files. Loop through your list using FileTime to fill an array with the timestamps. The timestamps will be an integer. Use MinSpa to check which one in the array has the lowest timestamp(oldest).

Log in or register to post/reply in the forum.