Barry said:
Hello
I need to know the date and time of a file on a internet site
eg.
http://www.triple-xxx.com/not-porn/somefile.zip
An HTTP server isn't required to provide that information, so you
can't reliably get it.
The closest thing is the value of the Last-Modified header, which the
standard (RFC 2616) says SHOULD be sent "whenever feasible". But that
leaves a lot of wiggle room. You're not guaranteed to get a
Last-Modified header in the server's response. And even if you do, of
course, there's no guarantee that it's correct.
Also, servers are allowed to cache response entities, so even with a
trustworthy server you should check for an Age header and assume the
resource could have been modified at any point in that time. (Age
indicates how long the entity has been in the cache; the server might
not check for updates until the cached copy reaches its expiration time.)
And the server's clock may not be synchronized with yours; the value
of the Date header (which the server must provide in most, though not
all, cases) can be used to estimate skew between the clocks, but it's
additional work.
is there some way to get the date and time as i need to check the date and
time (for comparison) before downloading.
HTTP/1.1 incorporates a fairly sophisticated caching mechanism. That's
what all HTTP clients should use to determine whether a resource has
been updated.
In this case, the If-Modified-Since request header looks like the best
approach. See RFC 2616 sec 14.28 (from rfc-editor.org and various
other sources).
Is that available through WebClient? I don't know. (I might get a
chance tomorrow to look it up.) If not, you need a better client
interface.