### Get File last modification datetime

Various options to get the last modification date & time for a file.
Option 1
Use API method from the java.io.file class (requires the JavaObject library)
Reference: http://docs.oracle.com/javase/7/docs/api/java/io/File.html
Example
' Get the last modification date & time for a file
' Parameter Path full filename
' Returns DateTime last modified as Long
' Example:
' Dim lm As Long = GetLastModified(File.DirApp & "\a.txt")
' Log(DateTime.Date(lm) & " " & DateTime.Time(lm))
`Sub GetLastModified(Path As String) As Long
Dim fileO As JavaObject
fileO.InitializeNewInstance("java.io.File", Array As Object(Path))
Return fileO.RunMethod("lastModified", Null)
End Sub`
Option 2
' Returns the filename from a fullpath
`Public Sub GetFileName(path As String) As String
' Define the JavaObject
Dim fileO As JavaObject
' Get the fileio class
fileO.InitializeNewInstance("java.io.File", Array As Object(path))
' Getthe filename
Return fileO.RunMethod("getName", Null)
End Sub`
' Returns the filepath from a fullpath
`Public Sub GetFilePath(path As String) As String
' Define the JavaObject
Dim fileO As JavaObject
' Get the fileio class
fileO.InitializeNewInstance("java.io.File", Array As Object(path))
' Get the filename and path
Dim n As String = fileO.RunMethod("getName", Null)
Dim p As String = fileO.RunMethod("getPath", Null)
p = p.Replace(n, "")
Return p
End Sub`
' Returns the last modified date & time from a fullpath
`Public Sub GetFileLastModified(path As String) As String
Dim d As Long
d = File.LastModified(GetFilePath(path), GetFileName(path))
Return DateTime.Date(d) & " " & DateTime.Time(d)
End Sub`

Changed: , Category: Files, File: T6C193M1377.htm, ID: 1377