FileVersionInfo.FileVersion 属性

获取文件版本号。

**命名空间:**System.Diagnostics
**程序集:**System(在 system.dll 中)

语法

声明
Public ReadOnly Property FileVersion As String
用法
Dim instance As FileVersionInfo
Dim value As String

value = instance.FileVersion
public string FileVersion { get; }
public:
property String^ FileVersion {
    String^ get ();
}
/** @property */
public String get_FileVersion ()
public function get FileVersion () : String

属性值

文件的版本号。

备注

通常,版本号显示为“主版本号.次版本号.内部版本号.专用部件号”。文件版本号是一个 64 位的数字,它按如下形式表示文件的版本号:

示例

下面的示例调用 GetVersionInfo 来获取“记事本”(Notepad) 的 FileVersionInfo。然后,它在文本框内输出文件说明和版本号。这段代码假定已经实例化 textBox1

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
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;
 }
    
public:
   [PermissionSet(SecurityAction::Demand, Name="FullTrust")]
   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 = String::Concat( "File: " + myFileVersionInfo->FileDescription + "\n" +
         "Version number: " + myFileVersionInfo->FileVersion );
   }

平台

Windows 98、Windows 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

.NET Framework 并不是对每个平台的所有版本都提供支持。有关受支持版本的列表,请参见系统要求

版本信息

.NET Framework

受以下版本支持:2.0、1.1、1.0

请参见

参考

FileVersionInfo 类
FileVersionInfo 成员
System.Diagnostics 命名空间
FileVersionInfo.FileBuildPart 属性
FileVersionInfo.FileMinorPart 属性
FileVersionInfo.FileMajorPart 属性
Version
FileVersionInfo.FilePrivatePart 属性