Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

c# how to print AssemblyFileVersion

Tags:

c#

How can I print in my log the version of the program that is running? In other words, can I access AssemblyFileVersion using Console.WriteLine?

Thanks Tony

like image 579
tony Avatar asked Aug 03 '10 21:08

tony


People also ask

What C is used for?

C is a powerful general-purpose programming language. It can be used to develop software like operating systems, databases, compilers, and so on.

What is the full name of C?

In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.

Why is C named so?

Quote from wikipedia: "A successor to the programming language B, C was originally developed at Bell Labs by Dennis Ritchie between 1972 and 1973 to construct utilities running on Unix." The creators want that everyone "see" his language. So he named it "C".

What is C of computer?

" " C is a computer programming language. That means that you can use C to create lists of instructions for a computer to follow. C is one of thousands of programming languages currently in use.


2 Answers

It looks like something like this would work:

public static string Version
{
    get
    {
        Assembly asm = Assembly.GetExecutingAssembly();
        FileVersionInfo fvi = FileVersionInfo.GetVersionInfo(asm.Location);
        return String.Format("{0}.{1}", fvi.ProductMajorPart, fvi.ProductMinorPart);
    }
}

From another post on SO.

like image 174
Alex Zylman Avatar answered Oct 25 '22 22:10

Alex Zylman


// Get the version of the current application.
Assembly assem = Assembly.GetExecutingAssembly();
AssemblyName assemName = assem.GetName();
Version ver = assemName.Version;
Console.WriteLine("{0}, Version {1}", assemName.Name, ver.ToString());

More on MSDN:

Version Class

like image 27
Leniel Maccaferri Avatar answered Oct 25 '22 23:10

Leniel Maccaferri