Click here to Skip to main content
14,424,584 members

Update Checker

Rate this:
3.12 (10 votes)
Please Sign up or sign in to vote.
3.12 (10 votes)
25 Sep 2019CPOL
Update Checker

Introduction

I was looking for a simple solution of a common problem: you have created an update of your application.

After you uploaded it to the server, you want that all the "old" applications (clients) get a message about this new version by checking for this automatically.

Background

My solution is very simple, the .NET DLL is small.

This XML file manages the updates (new Version 9.1.5 at https://leochapiro.de/data/TestApp.exe):

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<myCoolApp>
    <currentVersion>
        <major>9</major>
        <minor>1</minor>
        <build>5</build>
    </currentVersion>
    <path>https://myCoolApp.zip</path>
</myCoolApp>

The main function Check4Update() reads the XML file and parses it:

XmlDocument oDom = new XmlDocument();
oDom.Load(_sXmlConfig);

string str = oDom.SelectSingleNode("//currentVersion/major").InnerText;
Int32.TryParse(str, out _nMajor);

str = oDom.SelectSingleNode("//currentVersion/minor").InnerText;
Int32.TryParse(str, out _nMinor);

str = oDom.SelectSingleNode("//currentVersion/build").InnerText;
Int32.TryParse(str, out _nBuild); 

_sNewVersionPath = oDom.SelectSingleNode("//path").InnerText;

Using the Code

This solution is a .NET library (DLL) and can be used in every C# project by adding it as reference:

Image 1

Then you only need to create an instance of it:

axcsCheck4Update.axMain oCheckClient = new axcsCheck4Update.axMain(txtXml.Text);

int nMajor = oCheckClient.GetVersion(axcsCheck4Update.enVerion.EMajor);
int nMinor = oCheckClient.GetVersion(axcsCheck4Update.enVerion.EMinor);
int nBuild = oCheckClient.GetVersion(axcsCheck4Update.enVerion.EBuild);

string strPath = oCheckClient.GetNewVersionPath();

After getting the current version's number, you can compare it to your version's number:

// Get my own version's numbers
Assembly assembly = Assembly.GetExecutingAssembly();
FileVersionInfo fileVersionInfo = FileVersionInfo.GetVersionInfo(assembly.Location);

int nAppMajor = fileVersionInfo.FileMajorPart;
int nAppMinor = fileVersionInfo.FileMinorPart;
int nAppBuild = fileVersionInfo.FileBuildPart;

And, if they are different, you can point users to this new version like this:

Image 2

History

  • Version 1.0.0 released

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

_duDE
Software Developer
Germany Germany

I'm a software developer living in Germany with my family (wife & 2 sons).
My hobbies: sport, traveling, books (former reading, now hearing).
Welcome to my homepage: http://leochapiro.de

Comments and Discussions

 
Questionlink is broken, and ... Pin
BillWoodruff29-Sep-19 23:08
mveBillWoodruff29-Sep-19 23:08 
AnswerRe: link is broken, and ... Pin
_duDE1-Oct-19 5:23
professional_duDE1-Oct-19 5:23 
QuestionVery Handy Pin
  Forogar  26-Sep-19 4:22
professional  Forogar  26-Sep-19 4:22 
AnswerRe: Very Handy Pin
_duDE27-Sep-19 0:40
professional_duDE27-Sep-19 0:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Tip/Trick
Posted 24 Sep 2019

Tagged as

Stats

2.8K views
143 downloads
4 bookmarked