Application.ProductVersion 屬性
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得與這個應用程式關聯的產品版本。
public:
static property System::String ^ ProductVersion { System::String ^ get(); };
C#
public static string ProductVersion { get; }
member this.ProductVersion : string
Public Shared ReadOnly Property ProductVersion As String
產品版本。
下列程式碼範例會取得這個屬性,並在文字方塊中顯示其值。 此範例要求 textBox1
已放在表單上。
private:
void PrintProductVersion()
{
textBox1->Text = "The product version is: {0}",
Application::ProductVersion;
}
C#
private void PrintProductVersion() {
textBox1.Text = "The product version is: " +
Application.ProductVersion;
}
Private Sub PrintProductVersion()
textBox1.Text = "The product version is: " & _
Application.ProductVersion
End Sub
一般而言,版本號碼會顯示為 主要數位。次要數位。組建編號。私用元件編號。 您可以藉由在元件資訊清單內設定元件版本來明確設定它。 如需詳細資訊,請參閱 組件資訊清單。
ProductVersion 會先查看包含主要可執行檔 AssemblyInformationalVersion
的元件是否有屬性。 如果這個屬性存在,則會用於 ProductVersion 和 CommonAppDataPath 。 如果這個屬性不存在,這兩個屬性都會改用可執行檔的版本。
產品 | 版本 |
---|---|
.NET Framework | 1.1, 2.0, 3.0, 3.5, 4.0, 4.5, 4.5.1, 4.5.2, 4.6, 4.6.1, 4.6.2, 4.7, 4.7.1, 4.7.2, 4.8 |
Windows Desktop | 3.0, 3.1, 5, 6, 7 |