In a normal Windows application I can use...
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.CheckForUpdate()
...to determine whether or not there is an update available.
I know I can use System.Reflection
and Assembly
and AssemblyName
to print the version of the application as it is currently running, but I don't know how to get it to compare that to what's been published most recently.
What is the equivalent to CheckForUpdate()
for a console application, without using ClickOnce?
You would need something server side that the application can use to find out what the most recent version is. Personally, I would go with a web service that returns the most recent version number and a url where it can be downloaded, but this could also be done with a static page that gets parsed for this information. The application starts up, checks it's version number to the one returned from the service. If the service reports a newer version use HttpWebRequest (or other method) to download the new version. If the new version is packaged as an installer you could then execute the installer and exit the currently running instance. If you want something more silent than an installer you will need a way of updating your exe in place. This is usually done by a 2nd application (the updater) that waits for the main application to exit and moves the new version of the exe in to place, then restarts the application. One thing to keep in mind is that for this to work the user that the application is running as will need to have permission to write to the program directory.
If this is more of a corporate environment where you want to use fileshares you could do it differently. Have the program check a well known shared directory for a text file with the most recent version and the path to the update. Parse the text file for the information the same as above, and grab the new version from the specified path using the system.io
namespace classes. It's basically the same operation, but using file paths instead of web requests.