FileVersionInfo.FileVersion Property
Gets the file version number.
[Visual Basic] Public ReadOnly Property FileVersion As String [C#] public string FileVersion {get;} [C++] public: __property String* get_FileVersion(); [JScript] public function get FileVersion() : String;
Property Value
The version number of the file.
Remarks
Typically, a version number is displayed as "major number.minor number.build number.private part number". A file version number is a 64-bit number that holds the version number for a file as follows:
- The first 16 bits are the FileMajorPart number.
- The next 16 bits are the FileMinorPart number.
- The third set of 16 bits are the FileBuildPart number.
- The last 16 bits are the FilePrivatePart number.
Example
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.
[Visual Basic] Public Sub GetFileVersion() ' Get the file version for the notepad. Dim myFileVersionInfo As FileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\Notepad.exe") ' Print the file name and version number. textBox1.Text = "File: " & myFileVersionInfo.FileDescription & ControlChars.Cr & _ "Version number: " & myFileVersionInfo.FileVersion End Sub 'GetFileVersion [C#] 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; } [C++] public: void GetFileVersion() { // Get the file version for the notepad. FileVersionInfo* myFileVersionInfo = FileVersionInfo::GetVersionInfo(S"%systemroot%\\Notepad.exe"); // Print the file name and version number. textBox1->Text = String::Format( S"File: {0}\nVersion number: {1}", myFileVersionInfo->FileDescription, myFileVersionInfo->FileVersion ); } [JScript] public function GetFileVersion() { //Get the file version for the notepad. var myFileVersionInfo : FileVersionInfo = FileVersionInfo.GetVersionInfo("%systemroot%\\Notepad.exe"); //Print the file name and version number. textBox1.Text = "File: " + myFileVersionInfo.FileDescription + '\n' + "Version number: " + myFileVersionInfo.FileVersion; }
Requirements
Platforms: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 family
See Also
FileVersionInfo Class | FileVersionInfo Members | System.Diagnostics Namespace | FileBuildPart | FileMinorPart | FileMajorPart | Version | FilePrivatePart