This is part 4 of a series, previous posts: part 1, part 2 and part 3.
After we got the download details in the previous post it's time to download the update.
yaTimer - The software I'm selling, and obviously the easiest way to track your time - is a small application with small updates, so it just uses the .net WebClient class to download the file from the server, it's simple and easy to write the code and we can move on.
On the other hand, if your application needs to download large files of the web you will soon discover the problem with this approach – it can't recover from failed downloads, and downloading large files over unreliable or slow connections often fails.
Fortunately there is a solution, Microsoft found this same problem with their windows update service, and they wrote a library for downloading large files that can resume broken downloads, this library is called BITS and is included with Windows 2000, XP, 2003 Server, Vista and later, but it does not run on NT/95/98/ME – if your application support those versions of Windows you have a problem.
For more details you should read about BITS on MSDN, if you use .net you can use one of the many BITS .net wrappers that can be found on the web.
Now that we finally downloaded the update it's time to install it. For the installation part there are two options, you can have an extendable modular updating framework with custom actions that needs to be able to update itself – or you can use something simple.
In the case of yaTImer, the update is packaged as a zip file, the file contains all the files that have changed since the previous version and a program file that applies the update. Your programming platform probably gives you all the tools you need to update the application, and you can use a programming language you know – not some obscure configuration format, and as a bonus, since the update program is downloaded with the update it never needs to update itself. You can even use your application setup program as the update file.
Now we have a working auto-update component, but it only works if you are running as an administrator and doesn't work at all under Vista, we will fix this in the next part of this series.
posted @ Sunday, July 01, 2007 5:59 PM