Problem checking file dates

Smee

Well-Known Member
Licensed User
Longtime User
I am trying o check to see if a file on a server is the same as the file stored locally. To do this I am using the following code

B4X:
For i = 0 To Files.Length - 1
           FileTimeStamp=DateTime.Date(Files(i).Timestamp)
   DateTime.Date(Files(i).Timestamp
   Log("FileTimeStamp= " & FileTimeStamp)
   NewStamp=DateTime.DateParse(FileTimeStamp)
   Log("NewStamp= " & NewStamp)
   OS=DateTime.Date(File.LastModified(File.DirInternal & "/cats/", Files(i).Name))
           OldStamp = DateTime.DateParse(OS)
   Log("OldStamp= " & OldStamp)

FileTimeStamp= 2011-09-11
NewStamp= 1315699200000
OS= 2011-09-19
OldStamp= 1316390400000

Above are the log prints. I cannot compare the dates directly but the stamp numbers are different when they should not be. It IS the same file.
Where am i going wrong?

Thanks

Joe

EDIT:
I can see that the modified date is changed when it is downloaded but how would i check it any other way
 
Last edited:

Smee

Well-Known Member
Licensed User
Longtime User
Ha replying to my own post

OK i got it, using date parse to check for the lowest number
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
If possible use some kind of hash/signature instead.
Sometimes the Date gets modified during transfer.

Thanks for the reply.

Yes i realised that when downloading the same file a couple of times. However that works in my favour because once it is downloaded it will pick up the fact that any file on the server with the same name which is uploaded after that will have a higher number therfore newer. ( I Hope:))

Cheers

Joe
 
Upvote 0

Smee

Well-Known Member
Licensed User
Longtime User
I just hope this is true for all cases though. I have noticed sometimes weird things happen when you copy or transfer a file.

Hell, I hope so
 
Upvote 0

thedesolatesoul

Expert
Licensed User
Longtime User
Just an example (this may not even affect you)
I downloaded a file on 14 Sept, so the Create and Modfied date are set to 14 Sept.
When I copied it today to somewhere, the new file had a create date of 20 Sept but a Modified date of 14 Sept.
...so well...im not sure how other filesystems handle this.
but anyway...your idea works great and has some additional advantages.
 
Upvote 0
Top