943,652 Members | Top Members by Rank

Ad:
  • C# Discussion Thread
  • Marked Solved
  • Views: 5786
  • C# RSS
Mar 18th, 2009
0

How to find my exe's path?

Expand Post »
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!
Similar Threads
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008
Mar 18th, 2009
0

Re: How to find my exe's path?

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 <SYSTEMDRIVE>\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.
Reputation Points: 57
Solved Threads: 64
Posting Whiz in Training
mcriscolo is offline Offline
218 posts
since Apr 2008
Mar 18th, 2009
0

Re: How to find my exe's path?

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..
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008
Mar 19th, 2009
1

Re: How to find my exe's path?

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
Team Colleague
Reputation Points: 186
Solved Threads: 147
Cookie... That's it
alc6379 is offline Offline
2,519 posts
since Dec 2003
Mar 19th, 2009
0

Re: How to find my exe's path?

Thank you very much.
Reputation Points: 10
Solved Threads: 1
Junior Poster in Training
konczuras is offline Offline
59 posts
since Oct 2008

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C# Forum Timeline: is there any way to run .net project without compiling?
Next Thread in C# Forum Timeline: how to access dynamically created windows controls?





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC