Daniel Bardsley
Daniel Bardsley

Reputation:

How do I obtain File Version info from a C++ exe in C#?

I need to get the File version information from an exe file originally written in C++ from a C# program.

Using Assembly.LoadFile(fullpath).GetName().Version results in a BadImageFormatException.

Can anyone help?

Cheers,

Dan

Upvotes: 3

Views: 2428

Answers (1)

Marc Gravell
Marc Gravell

Reputation: 1064184

Add a using System.Diagnostics, and then:

    FileVersionInfo info = FileVersionInfo.GetVersionInfo(path);

Then look at the various properties of info:

    Console.WriteLine(info.CompanyName);
    Console.WriteLine(info.ProductName);
    Console.WriteLine(info.LegalCopyright);
    Console.WriteLine(info.ProductVersion);

etc

Upvotes: 6

Related Questions