Using Server File Date & Time

This forum is not monitored by the SmartFTP staff. If you have a license please contact technical support by email.
Post Reply
psweet
Posts: 2
Joined: Wed Aug 30, 2006 12:24 pm

Using Server File Date & Time

Post by psweet » Wed Aug 30, 2006 12:30 pm

Hi,

When I down files thru the UI from a server the file & date timestamps on my local PC match those of the servers. However, when I use the sample script, downloadfilejs.wsf the file & date timestamps on my local PC do not match those on the server. They are the local PC time when the download finished. Is there a way to accomplish getting the local file & date timestamps in sync with the server?

Thanks!

mb
Posts: 12026
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: Using Server File Date & Time

Post by mb » Wed Aug 30, 2006 9:33 pm

You have to get the file time of the remote file after the transfer and then you set the file time of the local file.
There are 2 methods to get the remote file time:
1. With the GetFileTime() function if MDTM is supported. Time is in UTC.
2. With the ReadDirectory() function and then locate the file and the corresponding time in the Directory collection. Time is in local time.

Regards,
-Mat

psweet
Posts: 2
Joined: Wed Aug 30, 2006 12:24 pm

Re: Using Server File Date & Time

Post by psweet » Thu Aug 31, 2006 5:26 pm


You have to get the file time of the remote file after the transfer and then you set the file time of the local file.
There are 2 methods to get the remote file time:
1. With the GetFileTime() function if MDTM is supported. Time is in UTC.
2. With the ReadDirectory() function and then locate the file and the corresponding time in the Directory collection. Time is in local time.

Regards,
-Mat

Thanks Mat.

I was unable to get the GetFileTime() function to work properly. So, I implemented your second suggestion of using the ReadDirectory() function. I am able to get the file but when I get the date it is returned as a large number (i.e. 38959.169444). What am I doing wrong?

Also how do I go about modifying the local file to match this date/time?

Thanks!

mb
Posts: 12026
Joined: Thu Oct 11, 2001 1:24 pm
Display name: Mat (SmartFTP)
Contact:

Re: Using Server File Date & Time

Post by mb » Thu Aug 31, 2006 11:00 pm

Hello ...

The GetFileTime only works if the server supports MDTM. So you first try GetFileTime() and if it fails you use the ReadDirectory() method.
The Date property returns the time/date in a VARIANT time. This format is mostly used for VB6, VBScript and JavaScript. The FileTime property returns the time as a FILETIME struct. This is the preferred format if you use C++ or C#. I have quickly added a new property: UnixTime. It returns the seconds since 1970. This is a commonly used in C++, C# and others. Please install the new version from:
https://www.smartftp.com/ftplib/download

>Also how do I go about modifying the local file to match this date/time?
Depending on the language you use there is always a function to set the time of the local file. E.g. the WINAPI function is ::SetFileTime.

Regards,
-Mat

Post Reply