Source Code for How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

Here is the C# source code for the previous blog post How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever this code is for .net version 2.0 or 3.0

try
{
   System.Diagnostics.Process.Start("http://www.example.com/upgrade_from_version_1.htm");
}
catch
{
   // ignore exception, might be FireFox’s fault
}

Just let the system do the heavy lifting, it will automatically find the default browser for you and load the web page.

The try-catch is needed, some versions of FireFox will not handle this correctly and cause an exception (as well as an error message) – but it will still load the web page after throwing the exception.

Note that the url for this web page can never change, you never know if someone still has an old version of the software, so plan for it in advance.

How can you use Process.Start to open a web page? By default Process.Start uses Win32 API’s ShellExecute function (and not CreateProcess), ShellExecute is smart and can “execute” all sort of things including links and data files (for example, passing a doc file to Process.Start will load word it it’s installed).

posted @ Sunday, June 17, 2007 11:17 PM

Comments on this entry:

# article for idiots

Left by qq at 5/19/2009 3:02 PM

is this article for idiots?

# re: Source Code for How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

Left by Nguyen Huy Phu at 9/22/2009 12:48 PM

I want to study how to write auto update program

# re: Source Code for How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

Left by Wyatt at 2/16/2010 12:53 AM

We actually have an open source updater: http://wyday.com/wyupdate/

It's part of our larger product that creates patches & adds true automatic updating to your app: http://wyday.com/wybuild/

# re: Source Code for How To Write an Automatic Update System Part 1 – the Simplest Auto Update Ever

Left by cuong at 2/14/2012 6:22 AM

do you can seant fo me code auto update. ok

Your comment:



 (will not be displayed)


 
 
Please add 1 and 1 and type the answer here: