Click here to Skip to main content
Click here to Skip to main content
Technical Blog

Tagged as

Auto Updating Version Text

, 11 Jan 2010 CPOL
Rate this:
Please Sign up or sign in to vote.
I was making an application with an About dialog that shows the version number for the app. Rather than add the version number as static text, I made use of reflection to extract the version number from the assembly.

I was making an application with an About dialog that shows the version number for the app. Rather than add the version number as static text, I made use of reflection to extract the version number from the assembly. If you are interested in doing the same in your application, you can use the following code to get the version number text.

Regex versionRegex = new Regex("Version=(?\\d\\.\\d\\.\\d\\.\\d)");

String GetVersion()
{
    string fullName = (this.GetType().Assembly.FullName).ToString();
    Match m = versionRegex.Match(fullName);
    if(m.Success)
    {
        return String.Format("{0}", m.Groups["ver"].Value);
    }
    else
    {
        return "";
    }
}

License

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

Share

About the Author

Joel Ivory Johnson
Software Developer Razorfish
United States United States
I attended Southern Polytechnic State University and earned a Bachelors of Science in Computer Science and later returned to earn a Masters of Science in Software Engineering.

For the past few years I've been providing solutions to clients using Microsoft technologies for web and Windows applications.

While most of my CodeProject.com articles are centered around Windows Phone it is only one of the areas in which I work and one of my interests. I also have interest in mobile development on Android and iPhone. Professionally I work with several Microsoft technologies including SQL Server technologies, Silverlight/WPF, ASP.Net and others. My recreational development interest are centered around Artificial Inteligence especially in the area of machine vision.

Twitter:@J2iNet
Follow on   Twitter   LinkedIn

Comments and Discussions

 
-- There are no messages in this forum --
| Advertise | Privacy | Terms of Use | Mobile
Web04 | 2.8.150414.1 | Last Updated 12 Jan 2010
Article Copyright 2010 by Joel Ivory Johnson
Everything else Copyright © CodeProject, 1999-2015
Layout: fixed | fluid