ClickOnce deployment location

南楼画角 提交于 2020-01-03 13:06:51

问题


We have some special requirements:

  1. From our application, launch a ClickOnce application. It will download ClickOnce app to user's cache.
  2. After it's done, the main app needs to access some file downloaded into ClickOnce app folder.

Is there any way for the main app to know the location of ClickOnce installation folder?

Thanks, yyff


回答1:


Assuming the Click1 app is yours, you could save to some more accesible location. Normally you can write to User\Documents for example.




回答2:


You can do this by examining the executing assembly and retrieving the location.

System.Reflection.Assembly assm = System.Reflection.Assembly.GetExecutingAssembly();

This is the location of your ClickOnce deployment. --> assm.CodeBase




回答3:


Try the following

using System.Deployment.Application;
...
var dep = ApplicationDeployment.CurrentDeployment;
var path = dep.DataDirectory;

It may not be in the DataDirectory path but one of those properties is almost ceratinly what you are looking for.



来源:https://stackoverflow.com/questions/1467687/clickonce-deployment-location

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