次の方法で共有


FileVersionInfo.FileVersion プロパティ

ファイルのバージョン番号を取得します。

Public ReadOnly Property FileVersion As String
[C#]
public string FileVersion {get;}
[C++]
public: __property String* get_FileVersion();
[JScript]
public function get FileVersion() : String;

プロパティ値

ファイルのバージョン番号。

解説

通常、バージョン番号は "メジャー番号.マイナ番号.ビルド番号.プライベート パート番号" の形式で表示されます。ファイル バージョン番号は、ファイルのバージョン番号を示す 64 ビットの数値であり、次のような構成になっています。

使用例

GetVersionInfo を呼び出して、メモ帳の FileVersionInfo を取得する例を次に示します。次に、ファイルの説明とバージョン番号をテキスト ボックスに出力します。このコードは、 textBox1 がインスタンス化されていることを前提にしています。

 
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;
 }
    

必要条件

プラットフォーム: Windows 98, Windows NT 4.0, Windows Millennium Edition, Windows 2000, Windows XP Home Edition, Windows XP Professional, Windows Server 2003 ファミリ

参照

FileVersionInfo クラス | FileVersionInfo メンバ | System.Diagnostics 名前空間 | FileBuildPart | FileMinorPart | FileMajorPart | Version | FilePrivatePart