Download file if newer

  • Thread starter Thread starter Frederik
  • Start date Start date
F

Frederik

Hi all,

I want to build an update function into my windows forms application. I want
an xml file to be downloaded from a server, only if it is newer then the
existing one.

The DownloadFile method seems to be useful for downloading, but after that,
what would be the best way to check if the file on the server is more
recent? How can I check it without downloading the file?

Any help is appreciated,
Frederik
 
If the file in question is mapped to a network drive and you can access it,
you should be able to create a fileinfo object and use the creationtime
method. i.e.

FileInfo fi = new FileInfo("m:\remote\file.xml"); // or
\\\\server\\remote\\file.xml for unmapped resource
DateTime dt = fi.CreationTime();

For a remote xml file given by Url, you can use the WebClient to download
the file to a local store but its creation time will reflect the download,
not its original. Unless the remote web server is configured to supply that
info in the content headers, which its usually not, I am not sure how you
would obtain it...

ok,
aq
 
If your pulling the file from a server you could build a quick web
method that you would call to get an "update" package from. The package
could contain not only the XML version (if needed) but also have the
latest timestamp of the XML file on the server. If the date is past
your local file then you could init a file download and grab the file
from the server or if authentication was needed use a soap call to send
the xml to you.

We use a single web method to provide version checks and status checks
on 9 different client apps. Depending on the client's guid we pass back
version data. A different web method sends the xml data back to the
client after being hashed. I wouldn't use a web method to send back
more than 3-4k of .xml data though.
 
Back
Top