如何从C#中的C ++ exe获取文件版本信息?

时间:2022-09-01 16:35:57

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

我需要从C#程序中最初用C ++编写的exe文件中获取File版本信息。

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

使用Assembly.LoadFile(fullpath).GetName()。版本导致BadImageFormatException。

Can anyone help?

有人可以帮忙吗?

Cheers,

Dan

1 个解决方案

#1


6  

Add a using System.Diagnostics, and then:

添加使用System.Diagnostics,然后:

    FileVersionInfo info = FileVersionInfo.GetVersionInfo(path);

Then look at the various properties of info:

然后看一下info的各种属性:

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

etc

#1


6  

Add a using System.Diagnostics, and then:

添加使用System.Diagnostics,然后:

    FileVersionInfo info = FileVersionInfo.GetVersionInfo(path);

Then look at the various properties of info:

然后看一下info的各种属性:

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

etc