469,326 Members | 1,541 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,326 developers. It's quick & easy.

How to get Application Path?

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
5 147230
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
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
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
> 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
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.

Similar topics

11 posts views Thread by Timothy Shih | last post: by
3 posts views Thread by ramonred | last post: by
1 post views Thread by Keith | last post: by
2 posts views Thread by Ross | last post: by
6 posts views Thread by Ben Finney | last post: by
4 posts views Thread by =?Utf-8?B?VkIgSm9ubmll?= | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.