Page 1 of 1

Getting file information

Posted: Wed 13 Mar 2019, 19:26
by simong42
I'm trying to access information about a specific file - in particular, the creation date/time.
I can do this by generating a directory listing (thanks to this forum for their help in resolving my "dir /s" query), but for some reason, I get different date/times when looking at the file on different media (rounding / truncation maybe?).

I looked in the online help, and found information about reading through the contents of a directory, and deriving such attributes as creation date/time, but could not see how to get this for a *specific* file.

(And after looking at other threads in this forum, I found this wiki - ... nd_20files - and bookmarked it - but couldn't see an answer to this question there.)

Re: Getting file information

Posted: Sat 16 Mar 2019, 17:21
Hi Simon,

The technique shown in the manual under "Listing the disk directory" should allow you to find what you need?

Best wishes,


Re: Getting file information

Posted: Fri 22 Mar 2019, 11:13
Hi Simon,

Sorry to be so long getting back on this. With a bit of playing, and help from Richard, I've come up with this, which may help. It's a bit fiddly because some data gets returned in 16 bits, so an integer picks up two, while others are returned in 64 bits, so you need a long integer. Weirdly, the file size is 64 bits, but the "wrong way round", so you need to read it as high and low sections.

I'll have a think about making a function which takes a filetime and a systemtime structure and returns the requested bit of information, but I'll have to swot up a bit on passing structures to functions....

Best wishes,


Code: Select all

      DIM FileAttributes{atts%,creation%%,last_access%%,last_write%%,fsize_High%,fsize_Low%}
      DIM SystemTime{Y_M%,DoW_D%,Hr_Min%,Sec_MS%}


      SYS "GetFileAttributesExA",f$,0,FileAttributes{}
      PRINT "File size: ";FileAttributes.fsize_Low%
      PRINT "Creation time:"; FileAttributes.creation%%
      PRINT "Last access time:"; FileAttributes.last_access%%
      PRINT"For me, the last access time comes up the same as creation time!"
      PRINT "Last write time:"; FileAttributes.last_write%%
      SYS "FileTimeToSystemTime",^FileAttributes.creation%%,SystemTime{} TO flag%
      IF flag%=0 THEN PRINT "FAILED!"
      PRINT "Created in year: ";SystemTime.Y_M% AND &FFFF
      PRINT "Created in month: ";SystemTime.Y_M% >>16
      PRINT "Created on DoW: ";SystemTime.DoW_D% AND &FFFF
      PRINT "Created on Day: ";SystemTime.DoW_D% >>16
      PRINT "Created at Hr: ";SystemTime.Hr_Min% AND &FFFF
      PRINT "Created at Min: ";SystemTime.Hr_Min% >>16

      SYS "FileTimeToSystemTime",^FileAttributes.last_write%%,SystemTime{} TO flag%
      IF flag%=0 THEN PRINT "FAILED!"

      PRINT "Modified in year: ";SystemTime.Y_M% AND &FFFF
      PRINT "Modified in month: ";SystemTime.Y_M% >>16
      PRINT "Modified on DoW: ";SystemTime.DoW_D% AND &FFFF
      PRINT "Modified on Day: ";SystemTime.DoW_D% >>16
      PRINT "Modified at Hr: ";SystemTime.Hr_Min% AND &FFFF
      PRINT "Modified at Min: ";SystemTime.Hr_Min% >>16

Re: Getting file information

Posted: Sat 24 Aug 2019, 13:24
by Edja
Hi D. ,

On 22 Mar 2019 you 've posted some prototype code that deals with the FileAttributes.
I think you were still trying to solve a few details. I 've just tried the code you 've posted and it runs but doesn't produce any correct data.
Did you follow through on this ? If yes, would you be prepared to share the result ?
I could use a function that returns file attributes for a specific file (creation date, ...)