How can I get the FileVersion information of an executable file stored in memory as an array of bytes?

I need to read the FileVersion executable. The problem is that I do not have the actual file on disk, but only an array of bytes. The FileVersion API has only the GetVersionInfo(string fileName) method, it has no way to capture the version from the file.

I tried to learn the source using a decompiler, but it looks more complex than a simple copy / paste can do.

Is there a way to read the file FileVersion file, given that I have bytes of the contents of the file without writing the file to disk?

+5
source share
1 answer

Unfortunately, after many digging and exploring the source of .NET Core, the available Javascript libraries, etc. I decided that this is not easy (or even possible) and it’s not worth the pain to understand.

Instead, I went with a simpler approach:

  • Writing a file to disk at a temporary location
  • Read the version from a file on disk
  • Delete a file

The code is simple and simple .NET code, no fancy tricks or complex JS libraries.

0
source

Source: https://habr.com/ru/post/1268563/


All Articles