Monday, August 02, 2010

BitsUpdater

BitsUpdater is .NET library written in C# for automatic application update using Background Intelligent Transfer Service (BITS). This service is used by Windows Update and is friendly to network resources. Library has GUI tool for generating secure packages.
This project uses SharpBITS.NET library.
Usage
Use BitsUpdatePacker to create secure update package.
You will need to generate your certificate.
Select folders and file search options.
Copy package with UpdateManifest.xml to your server.
Set configuration properties to locate UpdateManifest.xml on your server.
Integrate BitsUpdater to your application and set your custom update process or use featured ApplicationLauncher example.
static void Main(string[] args)
{
   BitsUpdater updater = new BitsUpdater("http://chodounsky.net/projects/BitsUpdater.Example/UpdateManifest.xml"
                                                            , Directory);
   RegisterUpdaterEvents(updater);
   updater.ResumePreviousDownload();
   updater.CheckUpdateAsync();
}
private static void RegisterUpdaterEvents(BitsUpdater updater)
{
   updater.UpdateDownloaded += (s, e) =>
       {
           Console.WriteLine("Update package is downloaded. Starting to apply update.");
           updater.Update(PublicToken);
       };
   updater.UpdateDownloadError += (s, e) =>
       {
           Console.WriteLine("Download error(" + e.Code + ") occured: " + e.Description);
       };
Read more: Codeplex