Retrieve File Version Information

Problem

You want to retrieve file version information (such as the publisher of a file, its revision number, associated comments, and so on).

Solution

Use the GetVersionInfo method of the System.Diagnostics.FileVersionInfo class.

Discussion

In previous versions of Visual Basic, you needed to call Windows API functions to retrieve file version information. With the .NET Framework, you simply need to use the FileVersionInfo class and call the GetVersionInfo method with the filename as a parameter. You can then retrieve extensive information through the FileVersionInfo properties.

The FileVersionInfo properties are too numerous to list here, but the following code snippet shows an example of what you might retrieve:

Public ...

Get Microsoft® Visual Basic® .NET Programmer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.