SocketTools .NET Edition

HttpClient.GetFileTime Method (String, DateTime)

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

[Visual Basic]
Overloads Public Function GetFileTime( _
   ByVal fileName As String, _
   ByRef fileDate As Date _
) As Boolean
[C#]
public bool GetFileTime(
   string fileName,
   ref DateTime fileDate
);

Parameters

fileName
A string that specifies a file on the server. The file name should be specified using an absolute path that begins with a leading slash character.
fileDate
A System.DateTime structure passed by reference which will contain the file modification date and time when the method returns.

Return Value

This method returns a boolean value. If the method succeeds, the return value is true. If the method fails, the return value is false. To get extended error information, check the value of the LastError property.

Remarks

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.

When a request is made to the server for information about the file, the class library 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.

See Also

HttpClient Class | SocketTools Namespace | HttpClient.GetFileTime Overload List