Determining file version information with VB.NET

Did you know that VB.NET simplifies the process of obtaining file version information? Irina Medvinskaya shows you how to utilize the FileVersionInfo class and call its GetVersionInfo method to get this information.

In Visual Basic 6, you can get the file version information by using the API function calls. VB.NET simplifies the process by allowing you to use handy properties and methods to determine the specifics of a file version. To get this information, I'll show you how to utilize the FileVersionInfo class and call its GetVersionInfo method, which accepts the file name as a parameter.

For our example in Listing A, I will add a List Box control to the form (see Figure 1). Note: In order to run the example, you need to add this statement on the top of your form or module: Imports System.Diagnostics.FileVersionInfo.

I define the variable sFileName to hold the location of the executable for which I will get the version information. I also define the variable Info as a FileVersionInfo class and then add selected properties of the FileVersionInfo object to the list box, one by one. Figure 2 displays the result of running this example.

Miss a tip?

Check out the Visual Basic archive, and catch up on the most recent editions of Irina Medvinskaya's column.

Advance your scripting skills to the next level with TechRepublic's free Visual Basic newsletter, delivered each Friday. Automatically sign up today!

Editor's Picks

Free Newsletters, In your Inbox