FileVersionInfo.FileVersion 属性    
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
获取文件版本号。
public:
 property System::String ^ FileVersion { System::String ^ get(); };public string? FileVersion { get; }public string FileVersion { get; }member this.FileVersion : stringPublic ReadOnly Property FileVersion As String属性值
文件的版本号,当文件不包含版本信息时则为 null。
示例
以下示例调用 GetVersionInfo 以获取 FileVersionInfo 记事本的 。 然后,它会在文本框中打印文件说明和版本号。 此代码假定 textBox1 已实例化。
#using <System.dll>
using namespace System;
using namespace System::IO;
using namespace System::Diagnostics;
public ref class Class1
{
    
public:
    static void Main()
    {
        // Get the file version for the notepad.
        // Use either of the two following methods.
        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);
    }
};
int main()
{
    Class1::Main();
}
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);
    }
}
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
注解
通常,版本号显示为“major number.minor number.build number.private part number”。 文件版本号是保存文件的版本号的 64 位数字,如下所示:
- 前 16 位是 FileMajorPart 数字。 
- 接下来的 16 位是 FileMinorPart 数字。 
- 第三组 16 位是 FileBuildPart 数字。 
- 最后 16 位是 FilePrivatePart 数字。