File Timestamps

rbw152

Member
Licensed User
Longtime User
Hello all!

Not sure if this has been asked already, if so apologies.

Is there a way to return the time-stamp of a file on the device? I'm trying to access images in the camera roll folder, but since windows automatically gives the image a name (picture###.jpg) at the time of save, I cant search through the entire folder to find the last image taken (my code in the past inserted the timestamp into the filename itself, but this time it's a Windows app in control).

I've been using fileDialog as well as the standard 'file' keywords (fileSearch etc), so I can see/select the files. I just need to automatically get at the latest file in the collection.

Many thanks in advance!
 

rbw152

Member
Licensed User
Longtime User
I now have the FilesEx Library and it looks like what I need. I'm trying to use FileGetAttributes() but i'm not entirely sure how to use it. Do I need to stick it into an array? Putting it into a string variable comes back as '32'. I heard that i might need the Bitwise library. If so, where can I get that because I haven't seen it listed, only mentioned :\

Just testing how to use the new code below, but hopefully you can see what I'm doing wrong here:

B4X:
    Dim var1 As String
  
    Filesex.New1
    dlgImg.Show 'OpenDialog Control
    var1 = Filesex.FileGetAttributes(dlgImg.File)
    Msgbox(var1)
 

agraham

Expert
Licensed User
Longtime User
The attribute bits are listed in the Overview topic of the FilesEx help. They are logically ORed together. You can use the Bitwise library that is part of the standard Basic4ppc installation (in the Libraries folder) to test individual bits. For example your '32' is a single bit, 0x20, which means the only attribute that file has is that the Archive attribute is set.
 

rbw152

Member
Licensed User
Longtime User
Thanks a bunch! That FilesEx library as saved my bacon! I appreciate your patience :)
 
Top