954,517 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

How to find my exe's path?

Hello!

I'm trying to create some files in the folder where my exe is located.

This works just fine in VS 2008 C# express, but when I publish the file, (e.g.: D:\Program), it refers to quite an other place (somewhere in my documents and settings' applications folder)

I've tried several different methods (Application.StarupPath, .ExecutablePath, tried the one with System.Reflections), but all resulted the same.

Have you got any ideas?

Thanks in advance!

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

I take it that when you say "publish", you are using the publish command from the "Build" menu... if that's the case, then yes, when you get the output package from the Publish process, and then install it, it does install it into a subfolder of \Documents and Settings\User\Local Settings\Apps\2.0. That is the folder you are seeing when you get the value from the "Application.StartupPath" property.

If you just copy your EXE (and any required supporting files) from your "Debug" (or "Release") folder to another location on your machine, the "Application.StartupPath" property will show you the correct location.

mcriscolo
Posting Whiz in Training
218 posts since Apr 2008
Reputation Points: 57
Solved Threads: 64
 

Thank you, this seems to be the case.

Now, is there any way to define where do I like to install my app?
The setup tool don't allow me anything, just works a little, then it installs to that folder..

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

You may have to create a custom deployment package to do this-- the default MSI creator doesn't afford you many options, but the deployment package project does:

http://msdn.microsoft.com/en-us/library/ms228283.aspx

alc6379
Cookie... That's it
Team Colleague
2,820 posts since Dec 2003
Reputation Points: 186
Solved Threads: 147
 

Thank you very much.

konczuras
Junior Poster in Training
59 posts since Oct 2008
Reputation Points: 10
Solved Threads: 1
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You