Export (0) Print
Expand All

FileVersionInfo.GetVersionInfo Method

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

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

public static FileVersionInfo GetVersionInfo(
	string fileName
)

Parameters

fileName
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.

ExceptionCondition
FileNotFoundException

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.


using System;
using System.IO;
using System.Diagnostics;

class Class1
{
    public static void Main(string[] args)
    {
        // Get the file version for the notepad. 
        // Use either of the two following commands.
        FileVersionInfo.GetVersionInfo(Path.Combine(Environment.SystemDirectory, "Notepad.exe"));
        FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo(Environment.SystemDirectory + "\\Notepad.exe");


        // Print the file name and version number.
        Console.WriteLine("File: " + myFileVersionInfo.FileDescription + '\n' +
           "Version number: " + myFileVersionInfo.FileVersion);
    }

}

.NET Framework

Supported in: 4.5.2, 4.5.1, 4.5, 4, 3.5, 3.0, 2.0, 1.1, 1.0

.NET Framework Client Profile

Supported in: 4, 3.5 SP1

Windows 8.1, Windows Server 2012 R2, Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)

The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.

Show:
© 2014 Microsoft