yyff
yyff

Reputation: 159

ClickOnce deployment location

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

Upvotes: 5

Views: 2051

Answers (3)

RobinDotNet
RobinDotNet

Reputation: 11877

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

Upvotes: 4

Henk Holterman
Henk Holterman

Reputation: 273244

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

Upvotes: 2

JaredPar
JaredPar

Reputation: 754725

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.

Upvotes: 3

Related Questions