Where Do Clickonce Apps Install
Nov 04, 2016 To specify prerequisites to install with a ClickOnce application. With a project selected in Solution Explorer, on the Project menu click Properties. Select the Publish pane. Click the Prerequisites button to open the Prerequisites dialog box.
I need to write a file in the same folder where a console ClickOnce .application
(executable file) resides. The folder where it launches from.
I tried using Application.StartupPath
& Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
but the path is pointing to a subfolder under c:Documents & Settings
. How do I get the path where the .application
resides in?
Download Clickonce Application
Tony_HenrichTony_Henrich8 Answers
To find the folder location, you can just run the app, open the task manager (CTRL-SHIFT-ESC), select the app and right-click|Open file location.

path is pointing to a subfolder under c:Documents & Settings
That's right. ClickOnce applications
are installed under the profile of the user who installed them. Did you take the path that retrieving the info from the executing assembly gave you, and go check it out?
On windows Vista and Windows 7, you will find the ClickOnce cache here:
On Windows XP, you will find it here:
Where Do Clickonce Apps Install
slavooApplicationDeployment.CurrentDeployment.ActivationUri might work
'A zero-length string if the TrustUrlParameters property in the deployment manifest is false, or if the user has supplied a UNC to open the deployment or has opened it locally. Otherwise, the return value is the full URL used to launch the application, including any parameters.'
BUT what I think you really want is ApplicationDeployment.CurrentDeployment.DataDirectory which gives you a folder you can write data to. When you update the application anyways you'll lose what was in the original .exe folder, but you can migrate the data directory over to a new version of the app. Your app can write to this folder with whatever log files it has - and I'm pretty sure its guaranteed to be writable.
Simon_WeaverSimon_WeaverI'm using Assembly.GetExecutingAssembly().Location
to get the path to a ClickOnce
deployed application in .Net 4.5.1.
However, you shouldn't write to any folder where your application is deployed to ever, regardless of deployment method (xcopy, ClickOnce, InstallShield, anything) because those are usually read only for applications, especially in newer Windows versions and server environments.
An app must always write to the folders reserved for such purposes. You can get the folders you need starting from Environment.SpecialFolder Enumeration. The MSDN page explains what each folder is for:http://msdn.microsoft.com/en-us/library/system.environment.specialfolder.aspx
I.e. for data, logs and other files one can use ApplicationData
(roaming), LocalApplicationData
(local) or CommonApplicationData
.For temporary files use Path.GetTempPath
or Path.GetTempFileName
.
The above work on servers and desktops too.
EDIT:Assembly.GetExecutingAssembly()
is called in main executable.
Where Do Clickonce Apps Get Installed
ClickOnce applications DO reside in a subdirectory of C:Documents & Settings. They don't have 'clean' installation directories because the local files are essentially 'temporarily' downloaded to allow the application to run on the local PC and execution of the application is controlled from the ClickOnce server that they are deployed on depending on publishing settings (Checking for updates, version requirements, etc).
NebuSoftNebuSoftAfter some exhaustive searching, I've finally found a way to find the obfuscated folder names via the registry. Here's a simple method for fetching them:
FrankerZFrankerZHere's what I found that worked for being able to get the deployed folder location of my clickonce application and that hasn't been mentioned anywhere I saw in my searches, for my similar, specific scenario:
- The clickonce application is deployed to a company LAN network folder.
- The clickonce application is set to be available online or offline.
- My clickonce installation URL and Update URLs in my project properties have nothing specified. That is, there is no separate location for installation or updates.
- In my publishing options, I am having a desktop shortcut created for the clickonce application.
- The folder I want to get the path for at startup is one that I want to be accessed by the DEV, INT, and PROD versions of the application, without hardcoding the path.
Here is a visual of my use case:
- The blue boxed folders are my directory locations for eachenvironment's application.
- The red boxed folder is the directory I want to get the path for(which requires first getting the app's deployed folder location'MyClickOnceGreatApp_1_0_0_37' which is the same as the OP).
I did not find any of the suggestions in this question or their comments to work in returning the folder that the clickonce application was deployed to (that I would then move relative to this folder to find the folder of interest). No other internet searching or related SO questions turned up an answer either.
All of the suggested properties either were failing due to the object (e.g. ActivationUri) being null, or were pointing to the local PC's cached installed app folder. Yes, I could gracefully handle null objects by a check for IsNetworkDeployed - that's not a problem - but surprisingly IsNetworkDeployed returns false even though I do in fact have a network deployed folder location for the clickonce application. This is because the application is running from the local, cached bits.
The solution is to look at:
AppDomain.CurrentDomain.BaseDirectory
when the application is being run within visual studio as I develop andSystem.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdateLocation
when it is executing normally.
System.Deployment.Application.ApplicationDeployment.CurrentDeployment.UpdateLocation
correctly returns the network directory that my clickonce application is deployed to, in all cases. That is, when it is launched via:
- setup.exe
- MyClickOnceGreatApp.application
- The desktop shortcut created upon first install and launch of the application.
Here's the code I use at application startup to get the path of the WorkAccounts folder. Getting the deployed application folder is simple by just not marching up to parent directories:
Assuming the question is about accessing files in the application folder after the ClickOnce (true System.Deployment.ApplicationDeploy.IsNetworkDeployed) application is installed on the user's PC, their are three ways to get this folder by the application itself:
These work from VS IDE and from a deployed/installed ClickedOnce app, no 'true System.Deployment.ApplicationDeploy.IsNetworkDeployed' check required. ClickOnce picks up any files included in the Visual Studio 2017 project so really the application can access any and all deployed files using relative paths from within the application.

This is based on Windows 10 and Visual Studio 2017