Is there a way to check if a ClickOnce application is running the latest version

笑着哭i 提交于 2019-12-11 07:45:58

问题


I understand that ClickOnce applications can update automatically. However, the options offered by Microsoft are not what I am looking for.

If I check the version before the application starts, the startup is slower.

If I chek the version after the application starts, I don't know than a new version is available until the next startup.

I am looking for a boolean function to check if a new version is available. This would enable me to suggest to the user to restart the application.


回答1:


using System.Deployment.Application;

public bool IsUpdateAvailable()
{
    if (!ApplicationDeployment.IsNetworkDeployed) return false;

    return ApplicationDeployment.CurrentDeployment.CheckForUpdate();         
}

Of course, you might want to make this feature accessible via a button and wrap some UI around it, like this.



来源:https://stackoverflow.com/questions/1507209/is-there-a-way-to-check-if-a-clickonce-application-is-running-the-latest-version

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!