File Data and Time

  • Thread starter Thread starter Barry
  • Start date Start date
B

Barry

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

The above link is dummy (don't try it).

Using the class WebClient i can get the size of the file at download time ,
is there some way to get the date and time as i need to check the date and
time (for comparison) before downloading..

TIA
Barry
 
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.
 
Hi Muchael

Thanks for the detailed reply.
WebClient class does give some size in the Progress event i found it
incorrect.

My Client want the app to downalod files if they are newer then 24 hrs
(these files are updated every 24 hrs).

Barry
 
Barry said:
My Client want the app to downalod files if they are newer then 24 hrs
(these files are updated every 24 hrs).

I don't know if you're still working on this, but if you are, I just
had a moment to look at WebClient.

I'd suggest setting the WebClient object's CachePolicy property to a
new RequestCachePolicy object which has its Level set to
RequestCacheLevel.Revalidate. That should check to see if the object
is in the local cache. If it is, it should ask the server if a newer
version of the object is available, and either return the cached
object (if there is no newer version) or download the newer one.

Then you can compare the returned object with the one you already have
to determine whether it's different.
 
Back
Top