ApplicationDeployment.CurrentVersion 屬性

定義

取得目前執行中應用程式執行個體的部署版本。Gets the version of the deployment for the current running instance of the application.

public:
 property Version ^ CurrentVersion { Version ^ get(); };
public Version CurrentVersion { get; }
member this.CurrentVersion : Version
Public ReadOnly Property CurrentVersion As Version

屬性值

Version

目前的部署版本。The current deployment version.

範例

下列程式碼範例會定義方法,以判斷是否 ClickOnceClickOnce 已更新應用程式。The following code example defines a method that determines whether ClickOnceClickOnce has updated the application.

public:
    bool CheckForUpdateDue()
    {
        bool isUpdateDue = false;

        if (ApplicationDeployment::IsNetworkDeployed)
        {
            ApplicationDeployment^ dueAppDeployment =
                ApplicationDeployment::CurrentDeployment;
            TimeSpan^ updateInterval =
                DateTime::Now - dueAppDeployment->TimeOfLastUpdateCheck;
            if (updateInterval->Days >= 3)
            {
                isUpdateDue = true;
            }
        }

        return (isUpdateDue);
    }
private Boolean CheckForUpdateDue()
{
    Boolean isUpdateDue = false;

    if (ApplicationDeployment.IsNetworkDeployed)
    {
        ApplicationDeployment ad = ApplicationDeployment.CurrentDeployment;
        TimeSpan updateInterval = DateTime.Now - ad.TimeOfLastUpdateCheck;
        if (updateInterval.Days > 3)
        {
            isUpdateDue = true;
        }
    }

    return (isUpdateDue);
}
Private Function CheckForUpdateDue() As Boolean
    Dim isUpdateDue As Boolean = False

    If (ApplicationDeployment.IsNetworkDeployed) Then
        Dim AD As ApplicationDeployment = ApplicationDeployment.CurrentDeployment
        Dim updateInterval As TimeSpan = DateTime.Now - AD.TimeOfLastUpdateCheck
        If (updateInterval.Days > 3) Then
            isUpdateDue = True
        End If
    End If

    CheckForUpdateDue = isUpdateDue
End Function

備註

CurrentVersionUpdatedVersion如果已安裝新的更新,但您尚未呼叫,則會與不同 RestartCurrentVersion will differ from UpdatedVersion if a new update has been installed but you have not yet called Restart. 如果部署資訊清單設定為執行自動更新,您可以比較這兩個值,以判斷是否應該重新開機應用程式。If the deployment manifest is configured to perform automatic updates, you can compare these two values to determine if you should restart the application.

適用於

另請參閱