Jump to content


Photo

Using Server File Date & Time


  • Please log in to reply
3 replies to this topic

#1 Paul Sweet

Paul Sweet
  • Members
  • 2 posts

Posted 30 August 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!

#2 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 30 August 2006 - 09: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

#3 Paul Sweet

Paul Sweet
  • Members
  • 2 posts

Posted 31 August 2006 - 05: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!

#4 mb

mb

    Developer

  • Administrators
  • 11527 posts
  • Gender:
    Male
  • Location:
    Worldwide

Posted 31 August 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:
http://www.smartftp....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




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users