GetFileTime Method

Return the modification date and time for specified file on the remote server.

Syntax

object.GetFileTime( RemoteFile, FileDate )

Remarks

The GetFileTime method returns the modification date and time for the specified file on the remote server. The following arguments may be passed to this method:

RemoteFile
A string that specifies the name of the file on the server. The filename cannot contain any wildcard characters and must follow the naming conventions of the operating system the server is hosted on.
FileDate
A variable that will be set to the date and time that the file was last modified. The variable's data type may either be a Variant, String or Date.

This method uses the HEAD command to retrieve header information about the file without downloading the contents of the file itself. This requires that the server support at least version 1.0 of the protocol standard, or an error will be returned.

The server may not return a modification time for some resources. If the request to the server was successful and the file exists, but the server does not return a modification time, the method will return an empty string.

When a request is made to the server for information about the file, the control will attempt to keep the connection alive, even if the KeepAlive property has not been set to True. This allows an application to request the modification time and then download the file without having to write additional code to re-establish the connection. However, it is possible that the attempt to keep the connection open will fail. In that case, an error will be returned and the session will no longer be valid. If this happens, the method may still return a valid date and time. To determine if an error occurred, check the value of the LastError property.

The Localize property will determine if the returned file time is adjusted for the local timezone.

Return Value

A value of zero is returned if the operation was successful, otherwise a non-zero error code is returned which indicates the cause of the failure.

Example

The following example demonstrates how to retrieve the size a file on the server:

Dim dateFileTime As Date

nError = HttpClient1.GetFileTime(strFileName, dateFileTime)
If nError <> 0 Then
    MsgBox HttpClient1.LastErrorString, vbExclamation
    Exit Sub
End If

MsgBox strFileName & " was modified on " & dateFileTime

See Also

Localize Property, GetFileSize Method


Copyright © 2008 Catalyst Development Corporation. All rights reserved.