By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,667 Members | 1,296 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,667 IT Pros & Developers. It's quick & easy.

How to get Application Path?

P: n/a
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
Hi,

Use Application.StartupPath

Nirosh.

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #2

P: n/a
Try Win32 API function GetCommandLine(). It should return the command line
with full application path. Sorry if it is not true, I don't have personal
experience with that.

Eliyahu

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #3

P: n/a
Have you tried System.Reflection.Assembly.GetExecutingAssembly(). Location

/Mikael

"Frank Rizzo" <no****@nospam.com> skrev i meddelandet
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly(). GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.

Thanks

Nov 13 '05 #4

P: n/a
> Environment.CurrentDirectory

??

run cmd.exe
cd c:\
run prog for example
c:\winnt\prog.exe
if try write Environment.CurrentDirectory

it return "c:\"


--
Selvin - Przemek Sulikowski
se****@osadkowski.com.pl
Nov 13 '05 #5

P: n/a
Sorry I got busy with my office work so I didn't saw this

................., (You yourself fill the blank with the suitable word)

Yes I read to the end of the post and I understood it and bellow is how I ask you to do, though your small brain cannot get it.

Application.StarupPath doesn't use Windows Forms nore it return the path as file://c/winnt/.../filename.exe where you cannot use for file loading etc..
It will return the path in a way, which you can create a FileInfo object and use to get almost all the details you need such as directory, directoryName, File Name, Full Path etc,,,,,,,,,,,,,,,,

Other than that it will give the actual path even if you load the assembly using a Shoutcut icon.

Nirosh.
"Frank Rizzo" <no****@nospam.com> wrote in message news:u6**************@TK2MSFTNGP10.phx.gbl...
Dude,

Did you read the post to the end?

Champika Nirosh wrote:
Hi,

Use Application.StartupPath

Nirosh.

"Frank Rizzo" <no****@nospam.com> wrote in message
news:eJ**************@tk2msftngp13.phx.gbl...
How to get Application Path?

I can't really use
System.Reflection.Assembly.GetExecutingAssembly( ).GetName().CodeBase

because it returns the path in the file://c/winnt/.../filename.exe
format, which I can't really use to open files, etc...

I also don't want to use System.Windows.Forms.Application.ExecutablePath
because I don't want to include Windows Forms for my console app.



Nov 15 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.