views:

316

answers:

2

I'd like to programatically determine the "publish location" (the location on the server which contains the installation) of the click-once application I'm running. I know that the appref-ms file contains this information and I could parse this file to find it but the application has no idea as to the location of the appref-ms file and I can't seem to find a way of determining this location.

Does anyone have any ideas how I can easily determine the publish location from within my application?

+5  A: 

There's a bunch of properties on System.Deployment.Application.ApplicationDeployment.CurrentDeployment that should answer your question.

You probably want to look at .ActivationURI, or .UpdateLocation for the path you want.

(It's probably worth checking that ApplicationDeployment.IsNetworkDeployed is true first otherwise you'll get an exception.)

Simon P Stevens
You rock! thanks.
rein
Haha. No problem.
Simon P Stevens
I think you will find that unless your application is online-only, or the user always clicks on a link to the deployment manifest and it runs it by invoking IE to fire it off, the ActivationURI will be blank. That's been my experience. Not sure about UpdateLocation, will be interested to see if it works.
RobinDotNet
A: 

If your application is offline/online, you can find the appref-ms file by looking for it on the start menu.

shortcutName = string.Concat(Environment.GetFolderPath(Environment.SpecialFolder.Programs), "\", publisher_name, "\", product_name, ".appref-ms");

where publisher_name and product_name are the entries on the Options dialog in the Publish property page.

Otherwise, you should be able to find it on the desktop.

RobinDotNet

RobinDotNet