views:

440

answers:

2

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?

A: 

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).

NebuSoft
Tony_Henrich
Oh, you want the deployment URL. Sorry, I didn't get that at all. Are you trying to get it from inside the ClickOnce application, or from an external application?
RobinDotNet
+1  A: 

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: c:\users\username\AppData\Local\Apps\2.0\obfuscatedfoldername\obfuscatedfoldername

On Windows XP, you will find it here: C:\Documents and Settings\username\LocalSettings\Apps\2.0\obfuscatedfoldername\obfuscatedfoldername

RobinDotNet

RobinDotNet
I understand all this. I want the folder from where I clicked on the app. I don't have access to the C:\Documents and Settings therefore I won't have access to the log file if I am going to use the folder path returned by that function and I don't want to use hard coded path values.
Tony_Henrich