B4J Question Get latest image in a folder

TomDuncan

Active Member
Licensed User
Longtime User
Hi All,
I have a web folder "10.1.1.99/view/images/" for example
This folder has images added to it in 30 second spacing.
What I would like is a method to display the latest image from a selected folder.
 

Roycefer

Well-Known Member
Licensed User
Longtime User
Warning, untested:
B4X:
Sub MostRecentFile(dir As String) As String
    Dim latest As String
    Dim t As Long = 0
    For Each f As String In File.ListFiles(dir)
        If Not(File.IsDirectory(dir,f)) Then
            If File.LastModified(dir,f)>t Then
                latest = f
                t = File.LastModified(dir,f)
            End If
        End If
    Next
    Return latest
End Sub
 
Upvote 0

TomDuncan

Active Member
Licensed User
Longtime User
that works like a charm if it is a folder on the hard drive. I can do a work-around for this.
The images are being saved into a folder on my Linux server. (10.1.1.99)
I am doing my design on a pc. So I will use an absolute Linux folder.
 
Upvote 0
Cookies are required to use this site. You must accept them to continue using the site. Learn more…