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.
library.
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);
};
updater.UpdateDownloadProgressChanged += (s, e) =>
{
Console.WriteLine("Downloaded " + e.BytesTranferred/1024 + "/" + e.BytesTotal/1024);
};
updater.UpdateChecked += (s, e) =>
{
if (e.UpdatesAvailable)
{
Console.WriteLine("New updates are ready to download!");
updater.Download();
}
else
{
Console.WriteLine("There are no new updates.");
}
};
}