C# Application Launcher with autoupdate. Part 2

By | 13. October 2016

Last time we started by defining project tasks and did some preparations (Part 1).

Fetching web page

Usually autoupdate launcher reads from update server one file with latest version info and other data. In our project we will read directory index listing. It is a bit more complicated as needs html parsing, but first issue to solve is same – fetching web page.

Simplest would be to use WebClient.

But as we want also to preset web connection timeout it is better to use HttpWebRequest (see for more info What difference is there between WebClient and HTTPWebRequest classes in .NET?)

Parsing  web response

If all went well we have now server directory listing page downloaded to string content. We use IIS but it might not be the always case, for update server Apache or other web server can be used. It means that index page would not be in very solid format, but may vary. Because of this our approach will be to parse all href (url link) tags. No reason to re-invent the wheel – Microsoft offers solution here: Regular Expression Example: Scanning for HREFs .

For showing links we add on form ListBox. Update files are planned to have zip and xml extensions. Later one is for release version and notes. So this is what we will show on screen. As a result index page parser will be something like this :

 

And will be attache here

For testing purposes we added some dummy files in update directory:

updates directory listing

So far we do  not have autoupdate so after clicking on update checking the result is:

launcher part 2

Next time’s task is to create local settings file,  update release file and check if update is needed.

Leave a Reply