' Name:        System.GetFileDates
'
' FileName:    filedate.ave
'
' Topics:      Misc, File, System, MS-DOS, Dir, Date, Access
'
' Title:       Find file date and time (Kleinschmidt T)
'
' Description: returns a string, in which you find the date/time
'              whether of the creation-date, last file-access or
'              or last writing-access of a given file  
'
' Requires:    MS-DOS-based System
'
' Self:        0 = the complete path and filename
'              1 = theAccess-Mode (c, a, w)
'
' Return:      theDateStr, the date and time of File-Access as String
'
' Creator:     Thore Kleinschmidt, Birgit Jäger GmbH
'
' CreationDate:15.03.00
'
' ==== SELF-OBJEKT ====

theShapeFileString = self.Get(0) '"D:\temp\ntuserid.ave" '
theDateTypString = self.Get(1) '"a" '
'c = Creation-Date
'a = Last Access
'w = Last Writing-Access
' =====================

theTempDir = "C:\temp\"  ' here you can specify your Temp-Dicrectory
' =====================

theBatchFileString = theTempDir+"datedir.bat"
theBatchFileName = theBatchFileString.AsFileName
theDateFileString = theTempDir+"date.txt"
theDateFileName = theDateFileString.AsFileName
theBatchFile = LineFile.Make(theBatchFileName,#FILE_PERM_WRITE)
theBatchFile.WriteElt("dir "+theShapeFileString+" "+"/t:"+ theDateTypString+" "+"> "+theDateFileString)
theBatchFile.Close
System.ExecuteSynchronous(theBatchFileString)
theDateFile = LineFile.Make(theDateFileName,#FILE_PERM_READ)
theDateFile.SetScratch(true)
for each pos in 1..theDateFile.GetSize
  theDateStr = theDateFile.ReadElt
  'MsgBox.Info( theDateStr, pos.AsString )

  if (theDateFile.getPos=6) then
    break
  end
end
theDateFile.Close
if (File.CanDelete(theBatchFileName)) then
  File.Delete(theBatchFileName)
end
theDateStr = theDateStr.Left(17)

' ==== THE RETURN-VALUE ====

return theDatestr