Code archives/File Utilities/Get File Date

This code has not been declared by its author to be Public Domain code, and therefore should not be assumed to be so.

Download source code

Get File Date by Prof
(Posted 24 years ago)
This function will return the creation date of a given file. I have updated it to take into account 2k/XP OS's and it seems to work OK. It hasnt been tested on Win98/ME. If you have problems then let me know.
;'Get Creation Date' by The Prof for Blitzers everywhere!
;
; Workaround Only. Launches 'cmd.exe' to get the info.
;
Graphics 640,200,32,2

File$="c:\program files\BlitzPlus\Samples\Mak\BlitzPaint.bb"

CreationDate$=GetCreationDate$(File$)

Text 10,10,File$
Text 10,30,CreationDate$
Flip
WaitKey():End

; ********************************************************

Function GetCreationDate$(Filename$)
  ; This function returns the creation dates of filename$.
  ; The filename must include the complete path.
  ; Tested on XP Pro only. Your OS may differ.

  If FileType(Filename$)=1
     TempFile$=SystemProperty("tempdir")+"/cdate.txt"
     c$="cmd.exe /c dir "+Chr$(34)+filename$+Chr$(34)+" > "+Chr$(34)+TempFile$+Chr$(34)
     ExecFile(c$)

     ; We need a slight delay otherwise it runs too fast (On my
     ; machine anyway), and can cause an error when trying
     ; to open the output file. Increase if necessary. 
     Delay 50

     FileIn=ReadFile(TempFile$)
     ; Ignore the first 5 lines - just drive info etc...
     For N=1 To 5:l$=ReadLine(FileIn):Next
     l$=ReadLine(FileIn):CloseFile(FileIn)
     CreationDate$=Left$(l$,10)
  Else
     CreationDate$="The filename given doesn't appear to exist"
  EndIf
  Return CreationDate$
End Function