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 file size for some resources. This
is typically the case with scripts that generate dynamic content
because the server has no way of determining the size of the output
generated by the script without actually executing it. The server
may also not provide a file size for HTML documents which use
server side includes (SSI) because that content is also dynamically
created by the server. If the request to the server was successful
and the file exists, but the server does not return a file size,
the method will succeed but the file size returned to the caller
will be zero.
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 file size 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 file size. To determine if an
error occurred, check the value of the LastError
property.
Note that if the file on the server is a text file, it is
possible that the value returned by this method will not match the
size of the file when it is downloaded to the local system. This is
because different operating systems use different sequences of
characters to mark the end of a line of text, and when a file is
transferred in text mode, the end of line character sequence is
automatically converted to a carriage return-linefeed, which is the
convention used by the Windows platform.