FileVersionInfo.GetVersionInfo Method (String)


The .NET API Reference documentation has a new home. Visit the .NET API Browser on to see the new experience.

Returns a FileVersionInfo representing the version information associated with the specified file.

Namespace:   System.Diagnostics
Assembly:  System (in System.dll)

Public Shared Function GetVersionInfo (
	fileName As String
) As FileVersionInfo


Type: System.String

The fully qualified path and name of the file to retrieve the version information for.

Return Value

Type: System.Diagnostics.FileVersionInfo

A FileVersionInfo containing information about the file. If the file did not contain version information, the FileVersionInfo contains only the name of the file requested.

Exception Condition

The file specified cannot be found.

The following example calls GetVersionInfo to get the FileVersionInfo for Notepad and displays the file description and version number in the console window.

Imports System
Imports System.IO
Imports System.Diagnostics

Class Class1

    Public Shared Sub Main(ByVal args() As String)
        ' Get the file version for the notepad.
        ' Use either of the following two commands.
        FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "Notepad.exe"))
        Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\Notepad.exe")

        ' Print the file name and version number.
        Console.WriteLine("File: " + myFileVersionInfo.FileDescription + vbLf + "Version number: " + myFileVersionInfo.FileVersion)

    End Sub
End Class


to get the version information. Associated enumeration: FileIOPermissionAccess.Read


for full trust for the immediate caller. This class cannot be used by partially trusted code.

.NET Framework
Available since 1.1
Return to top