Sub CheckforUpdates
' make sure temp directory exists...
File.MakeDir(File.DirDefaultExternal,"tempdir")
' if the template exists in assets, copy it to the tempdir
If File.Exists(File.DirAssets, "temp.db") = True Then
File.Copy( File.DirAssets, "temp.db",File.DirDefaultExternal,"/tempdir/temp.db")
Else
' otherwise - no template exists - abort
Return
End If
' if no temp db exists in the default folder - this must be first time (do the template update)
If File.Exists(File.DirDefaultExternal, "temp.db") = False Then
File.Copy( File.DirDefaultExternal, "/tempdir/temp.db",File.DirDefaultExternal,"temp.db")
DoUpdates
Else
' compare the two dates of temp in each folder. If the copy in /tempdir is greater than
' that in the default dir - It must be new! Copy it to default and do update
Dim d1, d2 As Long
d1 = File.LastModified(File.DirDefaultExternal,"temp.db")
d2 = File.LastModified(File.DirDefaultExternal,"/tempdir/temp.db")
If d2 > d1 Then
File.Copy( File.DirDefaultExternal, "/tempdir/temp.db",File.DirDefaultExternal,"temp.db")
DoUpdates
End If
End If
End Sub