423,680 Members | 2,439 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 423,680 IT Pros & Developers. It's quick & easy.

How can I get my exe path?

P: n/a
Hi,
In Delphi I could use paramstr(0) to get the full path to my exe during
runtime.
Does anyone know the C# equivilent?

Thanks a bunch,

--
Tony Caduto
Inexpensive Corporate Messaging
AM Software Design
http://www.amsoftwaredesign.com
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
Tony Caduto wrote:
Hi,
In Delphi I could use paramstr(0) to get the full path to my exe during
runtime.
Does anyone know the C# equivilent?


System.Reflection.Assembly a = System.Reflection.Assembly.GetEntryAssembly
();
string baseDir = System.IO.Path.GetDirectoryName(a.Location);
--
Greetings
Jochen

Do you need a memory-leak finder ?
http://www.codeproject.com/tools/leakfinder.asp

Do you need daily reports from your server?
http://sourceforge.net/projects/srvreport/
Nov 16 '05 #2

P: n/a
You can use the Appliaction.StartupPath property for the same.

Sijin Joseph
http://www.indiangeek.net
http://weblogs.asp.net/sjoseph

Tony Caduto wrote:
Hi,
In Delphi I could use paramstr(0) to get the full path to my exe during
runtime.
Does anyone know the C# equivilent?

Thanks a bunch,

--
Tony Caduto
Inexpensive Corporate Messaging
AM Software Design
http://www.amsoftwaredesign.com

Nov 16 '05 #3

P: n/a
Jay
use the following
this.GetType().Assembly.CodeBase

"Tony Caduto" <ac*****@amsoftwaredesign.com> wrote in message
news:Ow**************@TK2MSFTNGP15.phx.gbl...
Hi,
In Delphi I could use paramstr(0) to get the full path to my exe during
runtime.
Does anyone know the C# equivilent?

Thanks a bunch,

--
Tony Caduto
Inexpensive Corporate Messaging
AM Software Design
http://www.amsoftwaredesign.com

Nov 16 '05 #4

P: n/a
Sijin Joseph wrote:
You can use the Appliaction.StartupPath property for the same.


This might not point to the dir of the EXE!

--
Greetings
Jochen
Nov 16 '05 #5

P: n/a
Jay wrote:
use the following
this.GetType().Assembly.CodeBase


This points to the dir of the current Assembly (if your assembly is NOT the
EXE it will might point to the wrong directory...)

--
Greetings
Jochen
Nov 16 '05 #6

P: n/a
On Sun, 29 Aug 2004 01:28:18 -0500, "Tony Caduto"
<ac*****@amsoftwaredesign.com> wrote:
Hi,
In Delphi I could use paramstr(0) to get the full path to my exe during
runtime.
Does anyone know the C# equivilent?


Application.ExecutablePath

This also includes the name of the .exe.

Use the static method Path.GetDirectoryname on the Executable string
to exclude the exenam.exe part.

Oz

--
A: Because it fouls the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing on usenet and in e-mail?
Nov 16 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.