How to get Application Path?

F

Frank Rizzo

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
 
E

Eliyahu Goldin

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
 
S

Selvin

Environment.CurrentDirectory

??

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

it return "c:\"
 
C

Champika Nirosh

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top