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
)
public static FileVersionInfo GetVersionInfo (
	String fileName
)
public static function GetVersionInfo (
	fileName : String
) : FileVersionInfo
Not applicable.

Parameters

fileName

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

Return Value

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 typeCondition

FileNotFoundException

The file specified cannot be found.

The following example calls GetVersionInfo to get the FileVersionInfo for the Notepad. Then it prints the file description and version number in a text box. This code assumes textBox1 has been instantiated.

public void GetFileVersion() {
    // Get the file version for the notepad.
    FileVersionInfo myFileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe");
 
    // Print the file name and version number.
    textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' +
       "Version number: " + myFileVersionInfo.FileVersion;
 }
    

Windows 98, Windows Server 2000 SP4, Windows Millennium Edition, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

Community Additions

ADD
Show:
© 2014 Microsoft