Using Server File Date & Time

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!

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


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!

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