473,385 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

How can I get my exe path?

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
6 64334
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
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
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

31
by: John Roth | last post by:
I'm adding a thread for comments on Gerrit Holl's pre-pep, which can be found here: http://tinyurl.com/2578q Frankly, I like the idea. It's about time that all of the file and directory stuff...
9
by: Bengt dePaulis | last post by:
I have a local directory that I want to include in my sys.path How to save it permanently? Regards /Bengt
70
by: Michael Hoffman | last post by:
Many of you are familiar with Jason Orendorff's path module <http://www.jorendorff.com/articles/python/path/>, which is frequently recommended here on c.l.p. I submitted an RFE to add it to the...
34
by: Reinhold Birkenfeld | last post by:
Hi, the arguments in the previous thread were convincing enough, so I made the Path class inherit from str/unicode again. It still can be found in CVS:...
2
by: Rob Cowie | last post by:
Hi, Given a string representing the path to a file, what is the best way to get at the filename? Does the OS module provide a function to parse the path? or is it acceptable to split the string...
1
by: William Stacey [MVP] | last post by:
I need a bullet proof way to combine a root and a relative path to form a FQ rooted path (similar to a VDir in IIS). Path.Combine alone will not do the job in all cases. I also need to be sure...
4
by: python | last post by:
Bad file names, i.e. filenames the OS considers illegal, will cause functions in the os.path module to raise an error. Example: import os.path print os.path.getsize( 'c:/pytest/*.py' ) On...
34
by: Alexnb | last post by:
Gerhard Häring wrote: No, it didn't work, but it gave me some interesting feedback when I ran it in the shell. Heres what it told me: Traceback (most recent call last): File...
8
by: moondaddy | last post by:
I'm posting code for a user control ( FunctionConnectorSelector) below which has 3 content controls in it. each content control uses a style from a resource dictionary merged into the app.xaml...
6
by: bukzor | last post by:
I have to go into these convulsions to get the directory that the script is in whenever I need to use relative paths. I was wondering if you guys have a better way: from os.path import dirname,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.