Game Development Reference
In-Depth Information
over how and when updates occur. ClickOnce exposes a programmatic API that
allows you to manually check for updates and apply them. This functionality is
available in the System.Deployment.Application namespace and has a variety of fea-
tures, depending on the need of the custom solution.
The following code shows the easiest way to programmatically check for updates
and synchronously deploy them, but keep in mind that there is much more flexi-
bility in the ClickOnce API than what is shown here.
try
{
ApplicationDeployment updater = ApplicationDeployment.CurrentDeployment;
UpdateCheckInfo updateInfo = updater.CheckForDetailedUpdate();
if (updateInfo.UpdateAvailable)
{
string message1 = “A newer version of this application is available. “;
string message2 = “Do you want to update the application now?”;
if (MessageBox.Show(message1 + message2,
“ClickOnce Demo Updater”,
MessageBoxButtons.YesNo)
== DialogResult.Yes)
{
updater.Update();
MessageBox.Show(“Please shutdown and restart the “ +
“application to start using the new version.”);
}
}
}
catch (DeploymentException exception)
{
MessageBox.Show(exception.Message);
}
When a new version is available and the update is downloaded, the new application
files are placed in the appropriate folder named after the version. The shortcut to
the application is then pointed at the new folder, which requires shutting down the
application and restarting to take advantage of the changes.
Search Nedrilad ::




Custom Search