问题
We have some special requirements:
- From our application, launch a ClickOnce application. It will download ClickOnce app to user's cache.
- 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