CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Feb 2002
    Location
    Surrey, England
    Posts
    99

    Question Obtaining application version information

    Could someone please enlighten me as to how I can read the version of a natively compiled application?

    Thanks!

  2. #2
    Join Date
    Jun 2003
    Location
    Malaysia (P.J)
    Posts
    410

    Re: Obtaining application version information

    You could use the Environment class

    e.g
    Environment.Version.Build
    Environment.Version.Major
    Environment.Version.Revision
    Back after a long hibernation.

  3. #3
    Join Date
    Jul 2005
    Location
    Sydney, Australia
    Posts
    1,080

    Re: Obtaining application version information

    Environment.Version will give you the version number of the .NET Framework.

    Are you asking how you can look at an executable in the file system and get it's version, as opposed to the version of your own app? If so then you would use FileVersionInfo.GetVersionInfo to get a FileVersionInfo object and then use the appropriate properties to get the information you need.
    Tutorials: Home & Learn | Start VB.NET | Learn VB.NET | C# Station | GotDotNet | Games in VB.NET 101 Samples: 2002 | 2003 | 2005 | More .NET 2.0 (VB.NET, C#) Articles: VB.NET | C# | ASP.NET | MoreFree Components: WFC | XPCC | ElementsEx | VBPP | Mentalis | ADO.NET/MySQL | VisualStyles | Charting (NPlot, ZedGraph) | iTextSharp (PDF) | SDF (CF) ● Free Literature: VB 2005 (eBook) | VB6 to VB.NET (eBook) | MSDN Magazine (CHM format) ● Bookmarks: MSDN | WinForms .NET | ASP.NET | WinForms FAQ | WebForms FAQ | GotDotNet | Code Project | DevBuzz (CF) ● Code Converter: C#/VB.NET | VB.NET/C# | VS 2005 add-in

  4. #4
    Join Date
    May 2002
    Posts
    511

    Re: Obtaining application version information

    You can also get this information and more from the Assembly.

    Code:
    using System.Reflection;
    
    Assembly exeAssembly = Assembly.GetExecutingAssembly();
    object[] attributes = exeAssembly.GetCustomAttributes( false );
    foreach( object attribute in attributes )
    {
        ...
     
        else if( attribute is AssemblyFileVersionAttribute )
        {
            this.fileVersionTextLabel.Text = ((AssemblyFileVersionAttribute)attribute).Version;
        }
        ...
    }

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured